|
| 1 | +# Example WatchOS Integration Configuration |
| 2 | + |
| 3 | +This directory contains example configurations demonstrating the enhanced watchOS integration features. |
| 4 | + |
| 5 | +## Directory Structure |
| 6 | + |
| 7 | +``` |
| 8 | +examples/ |
| 9 | + watchos-integration/ |
| 10 | + App_Resources/ |
| 11 | + iOS/ |
| 12 | + watchapp/ |
| 13 | + MyWatchApp/ |
| 14 | + watchapp.json # Watch app configuration |
| 15 | + Assets.xcassets/ |
| 16 | + Info.plist |
| 17 | + ContentView.swift |
| 18 | + watchextension/ |
| 19 | + MyWatchExtension/ |
| 20 | + extension.json # Extension configuration |
| 21 | + Info.plist |
| 22 | + InterfaceController.swift |
| 23 | + Frameworks/ |
| 24 | + Data.xcframework/ # Example shared framework |
| 25 | + nativescript.config.ts # Main project configuration |
| 26 | + README.md |
| 27 | +``` |
| 28 | + |
| 29 | +## Configuration Files |
| 30 | + |
| 31 | +### 1. nativescript.config.ts |
| 32 | + |
| 33 | +```typescript |
| 34 | +import { NativeScriptConfig } from '@nativescript/core'; |
| 35 | + |
| 36 | +const config: NativeScriptConfig = { |
| 37 | + id: 'com.example.watchapp', |
| 38 | + appPath: 'app', |
| 39 | + appResourcesPath: 'App_Resources', |
| 40 | + ios: { |
| 41 | + // Main app SPM packages |
| 42 | + SPMPackages: [ |
| 43 | + { |
| 44 | + name: 'Alamofire', |
| 45 | + repositoryURL: 'https://github.com/Alamofire/Alamofire.git', |
| 46 | + version: '5.6.4', |
| 47 | + libs: ['Alamofire'] |
| 48 | + } |
| 49 | + ], |
| 50 | + |
| 51 | + // Watch-specific configuration |
| 52 | + watchApp: { |
| 53 | + // SPM packages for watch targets |
| 54 | + SPMPackages: [ |
| 55 | + { |
| 56 | + name: 'SwiftUICharts', |
| 57 | + repositoryURL: 'https://github.com/AppPear/ChartView.git', |
| 58 | + version: '1.5.5', |
| 59 | + libs: ['SwiftUICharts'], |
| 60 | + // These will be applied to both watch app and extension targets |
| 61 | + }, |
| 62 | + { |
| 63 | + name: 'LocalWatchPackage', |
| 64 | + path: './WatchPackages/MyLocalPackage', |
| 65 | + libs: ['MyLocalPackage'] |
| 66 | + } |
| 67 | + ] |
| 68 | + } |
| 69 | + } |
| 70 | +}; |
| 71 | + |
| 72 | +export default config; |
| 73 | +``` |
| 74 | + |
| 75 | +### 2. watchapp.json |
| 76 | + |
| 77 | +Configuration for the watch app target: |
| 78 | + |
| 79 | +```json |
| 80 | +{ |
| 81 | + "frameworks": [ |
| 82 | + "WatchKit.framework", |
| 83 | + "UserNotifications.framework" |
| 84 | + ], |
| 85 | + "assetcatalogCompilerAppiconName": "AppIcon", |
| 86 | + "targetBuildConfigurationProperties": { |
| 87 | + "ENABLE_BITCODE": "NO", |
| 88 | + "SWIFT_VERSION": "5.0", |
| 89 | + "WATCHOS_DEPLOYMENT_TARGET": "7.0" |
| 90 | + }, |
| 91 | + "modules": [ |
| 92 | + { |
| 93 | + "name": "Data", |
| 94 | + "path": "Frameworks/Data.xcframework", |
| 95 | + "embed": true, |
| 96 | + "headerSearchPaths": [ |
| 97 | + "Frameworks/Data.xcframework/watchos-arm64_arm64_32", |
| 98 | + "Frameworks/Data.xcframework/watchos-arm64_arm64_32/Headers" |
| 99 | + ] |
| 100 | + }, |
| 101 | + { |
| 102 | + "name": "SharedModels", |
| 103 | + "path": "Frameworks/SharedModels.xcframework", |
| 104 | + "embed": true, |
| 105 | + "linkerFlags": ["-ObjC"] |
| 106 | + } |
| 107 | + ] |
| 108 | +} |
| 109 | +``` |
| 110 | + |
| 111 | +### 3. extension.json |
| 112 | + |
| 113 | +Configuration for the watch extension target: |
| 114 | + |
| 115 | +```json |
| 116 | +{ |
| 117 | + "frameworks": [ |
| 118 | + "WatchKit.framework", |
| 119 | + "ClockKit.framework", |
| 120 | + "WatchConnectivity.framework" |
| 121 | + ], |
| 122 | + "targetBuildConfigurationProperties": { |
| 123 | + "ENABLE_BITCODE": "NO", |
| 124 | + "SWIFT_VERSION": "5.0", |
| 125 | + "WATCHOS_DEPLOYMENT_TARGET": "7.0" |
| 126 | + }, |
| 127 | + "modules": [ |
| 128 | + { |
| 129 | + "name": "Data", |
| 130 | + "path": "Frameworks/Data.xcframework", |
| 131 | + "embed": false, |
| 132 | + "headerSearchPaths": [ |
| 133 | + "Frameworks/Data.xcframework/watchos-arm64_arm64_32" |
| 134 | + ] |
| 135 | + } |
| 136 | + ], |
| 137 | + "workspaceTarget": "SharedUtilities" |
| 138 | +} |
| 139 | +``` |
| 140 | + |
| 141 | +## Usage Scenarios |
| 142 | + |
| 143 | +See the main [watchOS Integration Guide](../watchos-integration.md) for detailed usage scenarios, troubleshooting, and best practices. |
| 144 | + |
| 145 | +## Quick Start |
| 146 | + |
| 147 | +1. Copy the configuration files to your project |
| 148 | +2. Adjust paths and package names to match your setup |
| 149 | +3. Build your project: |
| 150 | + ```bash |
| 151 | + ns build ios --for-device |
| 152 | + ``` |
| 153 | + |
| 154 | +## Additional Resources |
| 155 | + |
| 156 | +- [Main watchOS Integration Documentation](../watchos-integration.md) |
| 157 | +- [Apple Watch Programming Guide](https://developer.apple.com/documentation/watchkit) |
| 158 | +- [Swift Package Manager](https://swift.org/package-manager/) |
0 commit comments