Create a Pebble watch face project with Xcode

When working on a Pebble watch face on OS X, I like to use Xcode as development environment. I like to have autocompletion and the ability to jump to the method definitions. Also, although Xcode does not build the project, it will still show you feedback in the code editor about mistakes you make.

In this short post I will describe how to set up a pebble project with Xcode.

  1. Create a new project in Xcode of type ‘Command Line Tool’.
    Set the type to C and leave ARC checked off. It will create a folder hierarchy, which was in my case: dutch_time/dutch_time.
  2. Delete the inner folder. (dutch_time/dutch_time, in my case)

    Folder structure created by Xcode.

    Folder structure created by Xcode.

  3. Go in the Terminal and move to the outer folder (dutch_time). This folder should only contain the .xcodeproj file.
  4. Now create a new Pebble project, which in my case would be something like:
    ../../PebbleKit-v1.1/Pebble/tools/create_pebble_project.py ../../PebbleKit-v1.1/Pebble/sdk/ dutch_time
  5. In Xcode, you can now add the source file (dutch_time.c) created by the Pebble script.
  6. Xcode has created a target for the new project, and although it will not build the .pbw, you can link the project with libpebble.a from the /sdk/lib folder in the PebbleKit sdk.

    Link libpebble.a with your Xcode project.

    Link libpebble.a with your Xcode project.

  7. In Xcode you also add the headers from your projects /include directory (in my case /dutch_time/dutch_time/include).

When you have followed these steps, you can work with a bit more intelligent code editor on your Pebble project.