To set up the development environment for watchOS 2, create
the Xcode project, add the watchOS 2 framework, and set up the necessary
targets.
About this task
You can create your watchOS 2 project in Xcode and add the
watchOS 2 framework manually or with CocoaPods.
Procedure
- Create a watchOS 2 app in Xcode.
- Choose the File->New->Project option;
the Choose a template for your new project dialog
appears.
- Choose the watchOS 2/Application option,
click Next.
- Name the project and click Next.
- From the navigation dialog, choose the project folder.
The project navigation tree now contains a main app folder and
a [project name] WatchKit Extension folder and
target.
- Add the MobileFirst watchOS
2 framework.
Note: WatchOS 2 requires bitcode. From Xcode 7 the Build
Options is set to Enable Bitcode Yes (Build
Settings tab, Build Options section).
- Register both the main app and the WatchKit extension on
the server.
- Run mfpdev app register for each
Bundle ID: .
- com.worklight.[project_name]
- com.worklight.[project_name].watchkitextension
This creates two registered apps on the server.
For more
information on registering iOS apps see Registering iOS applications to MobileFirst Server.
- In Xcode, from the menu, navigate to the mfpclient.plist file
created by mfpdev and add it to the project.
- Once the mfpclient.plist appears
in the navigation tree select it to display the Target
Membership box. Select the WatchOSDemoApp
WatchKit Extension target in addition to the WatchOSDemoApp.

- Beginning with Xcode 7 TLS must be enforced, see Enforcing TLS-secure connections in iOS apps. Note that both the main
app folder and the WatchKit extension folder have info.plist files
that need to be updated accordingly.
Results
The Xcode project now contains a main app and a watchOS 2
app, each can be developed independently. For Swift, the entry point
for the watchOS 2 app is the
InterfaceController.swift file
in the [project name]
watchKit Extension folder.
For Objective C the entry point is
ViewController.m.
To
use the MobileFirst watchOS
2 API in your code, import the relevant header:
For Objective
C:
#import <IBMMobileFirstPlatformFoundationWatchOS/IBMMobileFirstPlatformFoundationWatchOS.h>
For
Swift:
import IBMMobileFirstPlatformFoundationWatchOS