You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With version 5.4 the NativeScript CLI introduces a Beta support for integrating a [WatchOS](https://developer.apple.com/watchos/) application in your iOS mobile app created with NativeScript.
362
+
363
+
#### Prerequisites
364
+
365
+
-**NativeScript CLI version 5.4** and above.
366
+
- NativeScript project.
367
+
-**Xcode 10** and above.
368
+
- Paired devices or simulators (**iPhone** and **iWatch** with **WatchOS 4.x/5.x** and above).
369
+
370
+
> **Note:** WatchOS 4.x won't work with the default Watch App created with Xcode. The user will have to manually set **_`WATCHOS_DEPLOYMENT_TARGET`_** in the configuration json (see below for details).
371
+
372
+
- WatchOS app created with **Objective-C** (Swift code [is **not** supported yet](https://github.com/NativeScript/nativescript-cli/issues/4541#issuecomment-491202270)).
373
+
374
+
#### WatchOS application in NativeScript.
375
+
376
+
To integrate your existing WatchOS application into your NativeScript project, execute the following steps:
377
+
378
+
1. Create **_Single View App_** from Xcode.
379
+
380
+
2. Add watch app target through **_File > New > Target > WatchKit App_**.
381
+
382
+
3. Add a name to your watch app, for example, **_MyFirstWatchApp_**. In the same screen verify that **Objective-C** is selected as your language.
383
+
384
+
> **Note** You can skip steps 1-3 if your Watch app is already created.
385
+
386
+
4. Copy the generated **_MyFirstWatchApp_** and **_MyFirstWatchAppExtension_** to **_.../apps/MyApp/app/App_Resources/iOS/watchapp/MyFirstWatchApp_** and **_.../apps/MyApp/app/App_Resources/iOS/watchextension/MyFirstWatchAppExtension_** respectively.
387
+
388
+
5. Inside the **_Info.plist_** of the Watch App replace the value of **_`WKCompanionAppBundleIdentifier`_** with **_`$(WK_APP_BUNDLE_IDENTIFIER)`_**.
389
+
390
+
6. Inside the **_Info.plist_** of the Watch Extension replace the
391
+
of **_`WKAppBundleIdentifier`_** with **_`$(WK_APP_BUNDLE_IDENTIFIER)`_**.
392
+
393
+
7. You can populate the **_Assets.xcassets_** of the Watch App and add the name of the **_`appiconset`_** to the **_.../apps/MyApp/app/App_Resources/iOS/watchapp/MyFirstWatchApp/watchapp.json_**:
394
+
395
+
```JSON
396
+
{
397
+
"assetcatalogCompilerAppiconName": "AppIcon"
398
+
}
399
+
```
400
+
401
+
8. You can modify the **_`WATCHOS_DEPLOYMENT_TARGET`_** of the Watch App by adding the value inside the **_watchapp.json _** file like this:
402
+
403
+
```JSON
404
+
{
405
+
"assetcatalogCompilerAppiconName": "AppIcon",
406
+
"targetBuildConfigurationProperties": {
407
+
"WATCHOS_DEPLOYMENT_TARGET": 4.1
408
+
}
409
+
}
410
+
```
411
+
412
+
9. Build & Run the NativeScript application.
413
+
414
+
```Shell
415
+
ns run ios
416
+
```
417
+
418
+
10. The application will be deployed and started on your iOS device/simulator. Make sure that the test iPhone is already paired with the testing iWatch. Once the iOS app starts, the Watch app will be automatically deployed on the testing iWatch device.
419
+
420
+
> **Note:** As of May 2019 the feature is still in _BETA_. Please report all issues, bugs and features related to the WatchOS functionality in [the tracking issue](https://github.com/NativeScript/nativescript-cli/issues/4541#issue-433686622).
0 commit comments