├── Images ├── 01.png ├── 02.png ├── 03.png ├── 04.png ├── 05.png ├── 06.png ├── 07.png ├── 08.png ├── 09.png ├── 10.png ├── 11.png ├── 12.png ├── 13.png ├── 14.png ├── 15.png ├── 16.png ├── 17.png ├── 18.png ├── 19.png └── 20.png └── README.md /Images/01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CocoaBob/Pebcode/f43e1e8f3aa5dafbf59eeb4c418ce1125d36329a/Images/01.png -------------------------------------------------------------------------------- /Images/02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CocoaBob/Pebcode/f43e1e8f3aa5dafbf59eeb4c418ce1125d36329a/Images/02.png -------------------------------------------------------------------------------- /Images/03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CocoaBob/Pebcode/f43e1e8f3aa5dafbf59eeb4c418ce1125d36329a/Images/03.png -------------------------------------------------------------------------------- /Images/04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CocoaBob/Pebcode/f43e1e8f3aa5dafbf59eeb4c418ce1125d36329a/Images/04.png -------------------------------------------------------------------------------- /Images/05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CocoaBob/Pebcode/f43e1e8f3aa5dafbf59eeb4c418ce1125d36329a/Images/05.png -------------------------------------------------------------------------------- /Images/06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CocoaBob/Pebcode/f43e1e8f3aa5dafbf59eeb4c418ce1125d36329a/Images/06.png -------------------------------------------------------------------------------- /Images/07.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CocoaBob/Pebcode/f43e1e8f3aa5dafbf59eeb4c418ce1125d36329a/Images/07.png -------------------------------------------------------------------------------- /Images/08.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CocoaBob/Pebcode/f43e1e8f3aa5dafbf59eeb4c418ce1125d36329a/Images/08.png -------------------------------------------------------------------------------- /Images/09.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CocoaBob/Pebcode/f43e1e8f3aa5dafbf59eeb4c418ce1125d36329a/Images/09.png -------------------------------------------------------------------------------- /Images/10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CocoaBob/Pebcode/f43e1e8f3aa5dafbf59eeb4c418ce1125d36329a/Images/10.png -------------------------------------------------------------------------------- /Images/11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CocoaBob/Pebcode/f43e1e8f3aa5dafbf59eeb4c418ce1125d36329a/Images/11.png -------------------------------------------------------------------------------- /Images/12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CocoaBob/Pebcode/f43e1e8f3aa5dafbf59eeb4c418ce1125d36329a/Images/12.png -------------------------------------------------------------------------------- /Images/13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CocoaBob/Pebcode/f43e1e8f3aa5dafbf59eeb4c418ce1125d36329a/Images/13.png -------------------------------------------------------------------------------- /Images/14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CocoaBob/Pebcode/f43e1e8f3aa5dafbf59eeb4c418ce1125d36329a/Images/14.png -------------------------------------------------------------------------------- /Images/15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CocoaBob/Pebcode/f43e1e8f3aa5dafbf59eeb4c418ce1125d36329a/Images/15.png -------------------------------------------------------------------------------- /Images/16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CocoaBob/Pebcode/f43e1e8f3aa5dafbf59eeb4c418ce1125d36329a/Images/16.png -------------------------------------------------------------------------------- /Images/17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CocoaBob/Pebcode/f43e1e8f3aa5dafbf59eeb4c418ce1125d36329a/Images/17.png -------------------------------------------------------------------------------- /Images/18.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CocoaBob/Pebcode/f43e1e8f3aa5dafbf59eeb4c418ce1125d36329a/Images/18.png -------------------------------------------------------------------------------- /Images/19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CocoaBob/Pebcode/f43e1e8f3aa5dafbf59eeb4c418ce1125d36329a/Images/19.png -------------------------------------------------------------------------------- /Images/20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CocoaBob/Pebcode/f43e1e8f3aa5dafbf59eeb4c418ce1125d36329a/Images/20.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Pebcode 2 | How to set up Xcode for [Pebble](https://getpebble.com) development. 3 | 4 | ## Prerequisites 5 | Before you continue, please make sure you have... 6 | 7 | * The latest version of the Pebble SDK, installed as per [these instructions](http://developer.getpebble.com/sdk/install/mac) 8 | * Xcode from [Mac App Store](https://itunes.apple.com/gb/app/xcode/id497799835?mt=12) 9 | 10 | ## Xcode, Meet Pebble 11 | 12 | Steps to build and run a Pebble project in Xcode: 13 | 14 | 1. **Create a new Xcode project** in Xcode 15 | 1. OS X -> Application -> **Command Line Tool** 16 | 2. Product Name: **MyProject** 17 | 3. Language: **C** 18 | 3. Next -> Create 19 | 4. Rename target **MyProject** to **HiddenTarget** 20 | 5. Delete main.c and its parent folder *MyProject* 21 | 2. Create a new Pebble project in Terminal 22 | 1. `cd PATH_TO_MyProject` 23 | 2. `pebble new-project MyProject` 24 | 3. Move all files from subfolder **MyProject** to its parent folder 25 | 4. Delete the subfolder **MyProject** 26 | 5. (So that `MyProject.xcodeproj` is together with all Pebble project files) 27 | 6. (So that the directory structure can be supported by [CloudPebble](cloudpebble.net)) 28 | 3. Add Pebble project files 29 | 1. Drag `appinfo.json`, `resources`, `src` from Finder to Xcode project navigator. (The left files list corresponding to `⌘+1`) 30 | 2. In the dialog 31 | 1. Added folders: Choose **Create groups** 32 | 2. Add to targets: Select **HiddenTarget** 33 | 4. Setup Xcode project's **Building Settings** 34 | 1. Select the project (top blue icon in the files list) 35 | 2. In the **Building Settings** tab 36 | 3. Double click the value of **Header Search Paths** and add 37 | 1. `~/Library/Application\ Support/Pebble\ SDK/SDKs/current/**` 38 | 5. Add a new target for **Build & Run**. 39 | 1. Select the project (top blue icon in the files list) 40 | 2. Menu: Editor -> Add Target... 41 | 3. OS X -> Application -> Command Line Tool 42 | 4. Product Name: **Basalt** 43 | 5. Delete main.c and it's parent folder *Basalt* 44 | 6. Setup target **Basalt**'s **Build Phases** 45 | 1. Delete all phases that can be deleted 46 | 1. Compile Sources 47 | 2. Link Binary With Libraries 48 | 3. Copy Files 49 | 2. Menu: Editor -> Add New Build Phase -> Add Run Script Build Phase 50 | 3. Paste the following scripts 51 | 52 | ``` 53 | osascript -e 'tell app "Terminal"' -e 'if not (exists window 1) then' -e 'do script ""' -e 'end if' -e 'activate' -e 'end tell' -e 'tell app "System Events" to keystroke "c" using control down' -e 'tell app "Terminal"' -e 'set ctx to do script "" in window 1' -e "do script \"cd ${SRCROOT}\" in ctx" -e 'do script "pebble build" in ctx' -e 'do script "pebble install --emulator basalt" in ctx' -e 'do script "pebble logs --emulator basalt" in ctx' -e 'end tell' 54 | ``` 55 | 7. Setup target **Basalt**'s Scheme to avoid a warning dialog 56 | 1. Menu: Product -> Scheme -> Basalt 57 | 2. Menu: Product -> Scheme -> Edit Scheme... (`⌘+<`) 58 | 3. Launch: Choose **Wait for executable to be launched** 59 | 60 | 8. Now you can press `⌘+B` to build & run your Pebble project, the emulator and the logs will be displayed automatically. 61 | 62 | Notes: 63 | 64 | 1. You can add another target for **Aplite** emulator, just modify the script to 65 | 66 | ``` 67 | osascript -e 'tell app "Terminal"' -e 'if not (exists window 1) then' -e 'do script ""' -e 'end if' -e 'activate' -e 'end tell' -e 'tell app "System Events" to keystroke "c" using control down' -e 'tell app "Terminal"' -e 'set ctx to do script "" in window 1' -e "do script \"cd ${SRCROOT}\" in ctx" -e 'do script "pebble build" in ctx' -e 'do script "pebble install --emulator aplite" in ctx' -e 'do script "pebble logs --emulator aplite" in ctx' -e 'end tell' 68 | ``` 69 | 2. You can add another target for real device test, just modify the script to (remember to change the PHONE_IP of your iOS/Android devices), please make sure your phone and your computer are in the same Wifi network. 70 | 71 | 72 | ``` 73 | PHONE_IP=192.168.1.2 74 | osascript -e 'tell app "Terminal"' -e 'if not (exists window 1) then' -e 'do script ""' -e 'end if' -e 'activate' -e 'end tell' -e 'tell app "System Events" to keystroke "c" using control down' -e 'tell app "Terminal"' -e 'set ctx to do script "" in window 1' -e "do script \"cd ${SRCROOT}\" in ctx" -e 'do script "pebble build" in ctx' -e "do script \"pebble install -v --phone $PHONE_IP --logs\" in ctx" -e "do script \"pebble logs -v --phone ${PHONE_IP}\" in ctx" -e 'end tell' 75 | ``` 76 | 3. You may get the following errors during building, you need to update Python security package in Terminal by typing `pip install requests[security]`. 77 | ``` 78 | /usr/local/lib/python2.7/dist-packages/requests/packages/urllib3 79 | /util/ssl_.py:79: InsecurePlatformWarning: A true SSLContext object is not 80 | available. This prevents urllib3 from configuring SSL appropriately and 81 | may cause certain SSL connections to fail. For more information, see 82 | https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning. 83 | ``` 84 | 4. **HiddenTarget** is used for supporting Syntax Highlighting and Suggest Completion. It's better to delete its Scheme as we won't build & run it. 85 | 1. Menu: Product -> Scheme -> Manage Schemes... 86 | 2. Choose HiddenTarget, then delete. 87 | 5. Everytime you add some new source files, remember to only check target **HiddenTarget**, uncheck all the others. 88 | 6. You may fail to upgrade the Pebble SDK on Yosemite or El Capitan with compiling errors, edit `~/pebble-dev/PebbleSDK-3.4/requirements.txt`, and change `gevent==1.0.2` to `gevent==1.1.b1`. ([Discussions](https://github.com/pebble/homebrew-pebble-sdk/issues/18)) 89 | 7. If your phone can't be connected during the installing, remember to close the Terminal window which is displaying the logs of your real Pebble watch. 90 | 8. Now we can install the apps through PebbleCloud! This is very helpful when your phone is on 3G/4G network! Remember to `pebble login` in Terminal before using this script! 91 | 92 | ``` 93 | osascript -e 'tell app "Terminal"' -e 'if not (exists window 1) then' -e 'do script ""' -e 'end if' -e 'activate' -e 'end tell' -e 'tell app "System Events" to keystroke "c" using control down' -e 'tell app "Terminal"' -e 'set ctx to do script "" in window 1' -e "do script \"cd ${SRCROOT}\" in ctx" -e 'do script "pebble build" in ctx' -e "do script \"pebble install -v --cloudpebble --logs\" in ctx" -e "do script \"pebble logs -v --cloudpebble\" in ctx" -e 'end tell' 94 | ``` 95 | 9. If you get compiler error `clang: error: unknown argument: '-meabi=5'` after installing Pebble SDK 4.0, check if the **Header Search Paths** setting has been updated correctly. 96 | 97 | ## But Why? 98 | 99 | You might be thinking there’s a lot of hoops to jump through here, so what’s value in doing so? Well, once setup you get the following: 100 | 101 | ### Syntax Highlighting 102 | 103 | ![](Images/17.png) 104 | 105 | ### Code Completion 106 | 107 | ![](Images/18.png) 108 | 109 | ### Build Support 110 | 111 | ![](Images/19.png) 112 | 113 | You can use ⌘+b to build your Pebble app, and you can even see the output from the build in the Report navigator. 114 | 115 | ### Quick Help 116 | 117 | ![](Images/20.png) 118 | 119 | I :heart: Pebble’s SDK developers for making sure the headers are so well documented. 120 | 121 | ### Syntax Checking 122 | 123 | This comes in really useful if you’ve recently moved to [Swift](https://developer.apple.com/swift/) and have therefore completely forgot about the need for semi-colons :smirk: 124 | 125 | --------------------------------------------------------------------------------