Implementing proximity-based interactions between a phone and watch

Interact with a nearby Apple Watch by measuring its distance to a paired iPhone.

Overview

Configure the Sample Code Project

You can run this sample either in the simulator or on paired devices. When running on paired devices, both the watch and iPhone must contain an Ultra Wideband chip.

To run on paired devices:

  1. Select the WatchNIDemo target, then change the bundle ID to <Your iOS app bundle ID>. Select the right team to let Xcode automatically manage your provisioning profile.

  2. Repeat step 1 for the WatchKit app and WatchKit Extension target. The bundle IDs should be <Your iOS app bundle ID>.watchkitapp and <Your iOS app bundle ID>.watchkitapp.watchkitextension respectively.

  3. Next, for the WatchKit app target, select the Info tab, and change the value of WKCompanionAppBundleIdentifier key to <Your iOS app bundle ID>.

  4. Finally, open the Info.plist file of the WatchKit Extension target, navigate to NSExtension > NSExtensionAttributes > WKAppBundleIdentifier key, and change the value of the key to <Your iOS app bundle ID>.watchkitapp.