NOTE! You are browsing legacy documentation. For latest visit docs.nativescript.org.

NativeScript Angular

iOS WatchOS Applications

With version 5.4 the NativeScript CLI introduces a Beta support for integrating a WatchOS application in your iOS mobile app created with NativeScript.

Prerequisites

  • NativeScript CLI version 5.4 and above.
  • NativeScript project.
  • Xcode 10 and above.
  • Paired devices or simulators (iPhone and iWatch with WatchOS 4.x/5.x and above).

    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).

  • WatchOS app created with Objective-C (Swift code is not supported yet).

WatchOS application in NativeScript.

To integrate your existing WatchOS application into your NativeScript project, execute the following steps:

  1. Create Single View App from Xcode.

  2. Add watch app target through File > New > Target > WatchKit App.

  3. Add a name to your watch app, for example, MyFirstWatchApp. In the same screen verify that Objective-C is selected as your language.

Note You can skip steps 1-3 if your Watch app is already created.

  1. 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.

  2. Inside the Info.plist of the Watch App replace the value of WKCompanionAppBundleIdentifier with $(WK_APP_BUNDLE_IDENTIFIER).

  3. Inside the Info.plist of the Watch Extension replace the of WKAppBundleIdentifier with $(WK_APP_BUNDLE_IDENTIFIER).

  4. 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:

    {
        "assetcatalogCompilerAppiconName": "AppIcon"
    }
    
  5. You can modify the WATCHOS_DEPLOYMENT_TARGET of the Watch App by adding the value inside the _watchapp.json _ file like this:

    {
        "assetcatalogCompilerAppiconName": "AppIcon",
        "targetBuildConfigurationProperties": {
            "WATCHOS_DEPLOYMENT_TARGET": 4.1
        }
    }
    
  6. Build & Run the NativeScript application.

    tns run ios
    
  7. 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.

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.