For up-to-date product documentation, see the IBM MobileFirst Foundation Developer Center.

Set up watchOS 2 development in Xcode

To set up the development environment for watchOS 2, create the Xcode project, add the watchOS 2 framework, and set up the necessary targets.


We can create your watchOS 2 project in Xcode and add the watchOS 2 framework manually or with CocoaPods.


  1. Create a watchOS 2 app in Xcode.
    1. Choose the File->New->Project option; the Choose a template for our new project dialog appears.
    2. Choose the watchOS 2/Application option, click Next.
    3. Name the project and click Next.
    4. 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.

    Watch extension folder

  2. Add the MobileFirst watchOS 2 framework.

    • To install the necessary frameworks with CocoaPods, see Adding MobileFirst SDK to an iOS Xcode project using CocoaPods and specifically the step for watchOS 2 (Adding frameworks for watchOS).
    • To install the necessary frameworks manually:
      1. Obtain the watchOS 2 framework from MobileFirst Operations Console. See Acquiring the MobileFirst SDK from the MobileFirst Operations Console.
      2. Select the [project name] WatchKit Extension folder in the left navigation pane.
      3. From the File menu, choose Add Files.
      4. Click the Options button and select the following:
        1. Copy items if needed and Create groups options.
        2. [project name] WatchKit Extension in the Add to targets section.
      5. Click Add.
      Now when you select the [project name] WatchKit Extension in the Targets section:

      • The framework path appears in the Framework Search Paths setting in the Search Paths section of the Build Settings tab.
      • The Link Binary With Libraries section of the Build Phases tab lists the IBMMobileFirstPlatformFoundationWatchOS.framework file:

        Xcode Watch extension Build Phases tab

      For information on how to set up frameworks for the main iOS app see Setting up the Xcode project for iOS manually.

    Note: WatchOS 2 requires bitcode. From Xcode 7 the Build Options is set to Enable Bitcode Yes (Build Settings tab, Build Options section).

  3. Register both the main app and the WatchKit extension on the server.
    1. 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.

    2. In Xcode, from the File->Add File menu, navigate to the mfpclient.plist file created by mfpdev and add it to the project.
    3. 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.

      Xcode targets

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


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

Parent topic: Developing for watchOS 2