The Apple Watch will be two years old this year. At the time of writing, it is the best and the most successful wearable device in the market. When it was initially launched, watchOS apps were completely dependent on the iPhone to run on the Apple Watch. Watch apps were just an extension of apps running on the phone. However, the watchOS 2 changed all that, with support for the native apps. This meant that watch apps can run fully on the Apple Watch without relying on iPhone and speed up things considerably.
Developers now have access to the device's built-in heart rate sensor, taptic engine, accelerometer, microphone and build in third-party complications to display information on the watch face. There are more exciting developer-oriented features that iOS developers can look at and build great apps for Apple Watch.
Recently, my colleague Mayur Sojrani got the opportunity to develop a watch app for one of our clients and explore some cool features. It was a POC (Proof of Concept) related to motion sensors using the accelerometer. With all his knowledge and experience the required functionality was achieved. You may read about Mayur’s experience with developing a fall detection application, at this link.
Now it was time to deploy the iOS App supporting the Watch App. We were supposed to provide the POC to the client, as he wished to test the app on his Apple Watch. As it was a POC, we thought of providing it as an ad hoc build rather than uploading it to TestFlight.
With Ad Hoc distribution, we can build and run the app on selected devices only. I started with the distribution process. This is when I figured out that it was something more than what we used to do for any iOS mobile App. Hence, let me guide you with some basic stuff. These are things you need to take care of while working on an Ad Hoc distribution of Apple Watch App.
Before we start
The following write-up is intended for beginners who need Ad Hoc distribution of iOS-WatchKit App.
Before we proceed, I assume that you are already familiar with the following prerequisites:
1. You are enrolled in iOS Developer Program.
2. You have created valid Development and Distribution Certificates.
3. You already know about registering App Id on iOS Development center.
4. You know how to create provisioning profiles for iOS App and use them in Xcode to develop and distribute builds.
Let’s dive into the process that would be specific to Apple Watch App bundle Ad Hoc Distribution.
Registering iOS device and Apple Watch
First, you need to register your iOS Device and the Apple Watch in iOS Development Center. You need to do this with their respective UDID on which you need to test the app. We are usually familiar with obtaining the UDID of the iOS Devices. However, to obtain the UDID of Apple Watch you need to follow the following steps:
Step 1. Open Xcode.
Step 2. Click Window.
Step 3. Click Devices from the menu.
Step 4. Click on iPhone in the sidebar of Devices.
You will view your Apple Watch info like Name, Model, Capacity, Battery, watchOS and Identifier under Paired Watch Information. Your Apple Watch UDID is the Identified highlighted in the image below. Use this UDID to register your Apple Watch on iOS Dev Centre.
Register App Id’s
Once you have done adding your devices, you need to register App Id’s for the three components listed below:
1. An iOS app that runs on your iOS device.
2. A Watch Extension that communicates between the iOS device and the Apple Watch.
3. A Watch App that actually runs on Apple Watch.
You can use the auto generated Bundle Identifiers of the above three components to register the App Id’s. So, basically you need to register three App Id’s and make sure that the Bundle Identifiers are in the following format:
Phone App's Bundle Id: com.company.MyProduct
Watch App's Bundle Id: com.company.MyProduct.watchkitapp
Watchkit's Extension Bundle Id: com.company.MyProduct.watchkitapp.watchkitextension
With addition to registration of App Id’s, you even need to be careful about following content in the respective plist files;
1. iPhone App Info.plist:
The Bundle Identifier can be like: com.company.MyProduct
2. WatchKit App Info.plist:
The bundle identifier in this file must be prefixed with the identifier of the iPhone App like: com.company.MyProduct.watchkitapp
The WKCompanionAppBundleIdentifier m key should contain the value that matches the bundle identifier of iPhone App.
Eg : com.company.MyProduct
3. Watchkit Extension Info.plist:
The bundle identifier in this file must be;
Also, the WKAppBundleIdentifier identifier must match with the WatchKit app bundle identifier: com.company.MyProduct.watchkitapp
I hope things are clear till this point. Now, let’s move to creating provisioning profiles.
Create Ad Hoc Distribution Provisioning Profiles
Once you have registered the App Id’s, it’s time to create Ad Hoc Distribution Provisioning Profiles. Each of the components mentioned above must have their respective provisioning profile which meets the following requirements.
1. The provisioning profile for the host app must contain the UDID of iPhone.
2. The provisioning profile for the watch extension must contain the UDID of iPhone.
3. The provisioning profile for the watch app must contain the UDID for the Apple Watch.
4. These three provisioning profiles must be of Ad Hoc type and should have the same certificate for production.
With this stuff, you are ready to download the provisioning profiles and use it to generate the Ad Hoc Distribution build. Make sure the respective provisioning profiles are set in code signing (release) to all the three iOS apps, Watchkit App and Watchkit extension. Archive the app and save it for Ad Hoc Distribution.
Hope, this blog would help the readers with Ad Hoc Distribution of Apple Watch App. The process is quite simple and same as any iOS App distribution albeit minor tweaks for WatchKit and WatchKit extension.
You are now able to distribute the app on your limited number of devices for different purposes as per your need. This concludes our article on Ad Hoc distribution of an Apple Watch app. You are welcome to share your questions and suggestions at firstname.lastname@example.org.