Pebble Smart-watch, Xcode 5 and OS X Mavericks

After stumbling a few times while setting up my development environment for the Pebble Smart-watch, I decided to write a step-by-step guide on the topic to save time and sanity to other developers coding their first application for Pebble using Xcode 5 under OS X Mavericks and iOS.

Things You’ll Will Need In Your iOS Device

  1. Update to iOS 7 just to be sure.
  2. Don’t bother downloading the Pebble app from the App Store (v1.x). You need to submit a form to receive an .ipa with the 2.x version.
  3. After receiving the .ipa file with the Pebble app v2.x, install it. Open your device’s Settings app, select Pebble and enable ‘Developer Mode’.
  4. Return to the home screen and open the Pebble app. Select ‘Developer Connection’ and enable it.

Things You Need In Your Pebble Smart-Watch

  1. Be sure you have opened the iOS Pebble app v2.x at least once.
  2. Put your Pebble in Recovery Mode: Press the Back button, the Up button and the Select button for at least 30 seconds until you see ‘Loading…’ on the screen.

    Don’t let that ‘Pebble’ screen fool you! Keep pressing those buttons until you can read ‘Loading…’.

  3. Re-pair your Pebble with your iOS device’s bluetooth.
  4. If your device suggests that an upgrade is available, refuse the upgrade.
  5. Open one of the following links from your iOS device, your phone will start upgrading your Pebble:

    If your serial number starts with a number, download Pebble Firmware 2.0-BETA2 for ev2_4..

    If your serial number starts with the letter Q, download Pebble Firmware 2.0-BETA2 for v1_5.

Things You Need In Your Computer

  1. Install the Xcode Command Line Tools by typing the following command in the Terminal:
    xcode-select --install
    

    If you have problems installing them via this command (‘Can’t install the software because it is not currently available from the Software Update server’ error), download the installer manually from the Developer Center.

    Don’t skip this step! The Command Line Tools are not installed by default in Xcode 5.

  2. Download the latest version of the Pebble SDK. Go and grab it from the Getting Started Guide, there is big orange button that reads ‘PEBBLE SDK’.
  3. Create a directory for all Pebble tools:
    mkdir ~/pebble-dev/
    
  4. Unzip the Pebble SDK inside that directory. You should end with something like: ~/pebble-dev/PebbleSDK-2.0-BETA2.
  5. Add the Pebble tool to your command line:
    echo 'export PATH=~/pebble-dev/PebbleSDK-2.0-BETA2/bin:$PATH' >> ~/.bash_profile
    
  6. Reload your shell configuration to make it available immediately
    source ~/.bash_profile
    
  7. Download the toolchain for OS X (arm-cs-tools-macos-universal-static.tar.gz).
  8. Extract that compressed file inside ~/pebble-dev/PebbleSDK-2.0-BETA2. Be sure you end with something like: ~/pebble-dev/PebbleSDK-2.0-BETA2/arm-cs-tools.
  9. Install the Python packet manager, pip:
    sudo easy_install pip
    
  10. And all the Python dependencies used by Pebble:
     pip install --user -r ~/pebble-dev/PebbleSDK-2.0-BETA2/requirements.txt
    

    If this last step fails, it is probably because you don’t have the Xcode Command Line Tools installed.

Things You Need In Your Xcode Project

  1. Include PebbleKit.framework and PebbleVendor.framework in your Xcode project.
  2. Link ExternalAccessory.framework, libz.dylib, CoreBluetooth.framework, CoreMotion.framework, CFNetwork.framework and MessageUI.framework.
  3. Add -ObjC to Other Linker Flags of your target’s Build Settings.
  4. In your Info.plist file, add the value com.getpebble.public to the Supported external accessory protocols array.
  5. Also in the Info.plist file, add the value App communicates with an accessory to the Required background modes array.
  6. In the Build Settings of your project, change Architecture’s value from $(ARCHS_STANDARD_INCLUDING_64_BIT) to $(ARCHS_STANDARD).

    Otherwise, you will bump with the following error:

    Undefined symbols for architecture x86_64:
      "_OBJC_CLASS_$_PBPebbleCentral", referenced from:
          objc-class-ref in NPViewController.o
    ld: symbol(s) not found for architecture x86_64
    

After all those steps, your watch, Mac, iPhone and Xcode should be ready to start coding.

Did somebody said ‘Hello World‘?

Happy coding!

Tweeting Developers

For a long time I saw Twitter as a source of mild entertainment which occasionally brought me up to update on something relevant.

But that point of view changed recently, when I cherry-picked who I’m following and discovered the interaction I can have with some great developers.

In no time it became a valuable tool that updates me on what’s happening in my tech niche, tips me about new interesting things to learn and puts me in touch with other cool people doing cool stuff.

But don’t take my word for granted. Leif Singer (@lsinger), a mad scientist from the University of Victoria in Canada, made a thorough research on How Software Developers Use Twitter.

He wrote a great post about it on his blog that I just can’t recommend enough. It includes a tl;dr and usage strategies for developers using Twitter. Pure gold.

Check it out. You know, for science!

Command that Terminal

In case somebody else is using the left and right arrows to navigate through typed commands, I’ve compiled a list of useful shortcuts for the Terminal:

  • Ctrl + A: Go to the beginning of the line.
  • Ctrl + E: Go to the end of line.
  • Ctrl + F: Move the cursor position one space forward.
  • Ctrl + B: Move the cursor position one space backward.
  • Alt + F: Move the cursor position one word forward.
  • Alt + B: Move the cursor position one word backward.
  • Ctrl + U: Clear the line before the cursor.
  • Ctrl + K: Clear the line after the cursor.
  • Alt + Del: Delete the word before the cursor.
  • Alt + D: Delete the word after the cursor.
  • Tab: Auto-complete file and directory names.
  • Ctrl + L: Clears the screen (same result as typing the clear command).
  • Ctrl + C: Terminate the running program; a timeless classic.

Edit: As noted by Parker Wightman (@parkerwightman), these same key bindings work in nearly every OSX text field.

As I grow older I found myself more and more comfortable working from the OSX Terminal, but I was annoyed by the “missing commands to navigate through the text”… Until I discovered them recently and my mind was blown.

Hope they are useful for somebody else too.