{"id":555,"date":"2020-11-02T12:47:26","date_gmt":"2020-11-02T12:47:26","guid":{"rendered":"https:\/\/willow.systems\/blog\/?p=555"},"modified":"2021-06-16T21:11:21","modified_gmt":"2021-06-16T20:11:21","slug":"pebble-sdk-installation-guide","status":"publish","type":"post","link":"https:\/\/willow.systems\/blog\/pebble-sdk-installation-guide\/","title":{"rendered":"Writing a Pebble app in 2020 Part 2 &#8211; Installing the SDK"},"content":{"rendered":"\n<p>In <a href=\"https:\/\/willow.systems\/blog\/writing-a-pebble-app-in-2020\/\" data-type=\"URL\" data-id=\"https:\/\/willow.systems\/blog\/writing-a-pebble-app-in-2020\/\">part one<\/a> of this 4 part series we covered the prerequisites you need to know to develop for Pebble watches. Part 2 will cover installing the SDK and Pebble emulator.<\/p>\n\n\n\n<!--more-->\n\n\n\n<p><\/p>\n\n\n\n<pre id=\"block-e63c92c7-4025-427a-8442-ba9ce5e36314\" class=\"wp-block-preformatted\">Part 1\n- <a href=\"https:\/\/willow.systems\/blog\/writing-a-pebble-app-in-2020\">Introduction<\/a>\n- <a href=\"https:\/\/willow.systems\/blog\/writing-a-pebble-app-in-2020\/#intro\">Why write a Pebble app in 2020<\/a>\n- <a href=\"https:\/\/willow.systems\/blog\/writing-a-pebble-app-in-2020\/#pebbleversions\">An explanation of the different Pebble devices &amp; platforms<\/a>\n- <a href=\"https:\/\/willow.systems\/blog\/writing-a-pebble-app-in-2020\/#jsvsc\">An introduction to Pebble apps<\/a>\n\nPart 2\n- <a href=\"https:\/\/willow.systems\/blog\/pebble-sdk-installation-guide\/#options\">Pebble SDK options<\/a>\n- <a href=\"https:\/\/willow.systems\/blog\/pebble-sdk-installation-guide\/#linuxinstall\">Installing the SDK<\/a>\n\nPart 3 (Coming soon)\n- Introduction to PebbleJS\n- Writing your first app\n- Calling an API for data\n\nPart 4 (Coming soon)\n- Writing an App configuration page\n- Advanced PebbleJS concepts<\/pre>\n\n\n\n<h2 id=\"options\">Pebble SDK options<\/h2>\n\n\n\n<p>The Pebble Software Development Kit (SDK) is the set of tools we need to build our Pebble app. It manages turning our code into something that can run on the watch, as well as some testing and debug tools too. Once we&#8217;ve got this setup, we can starting writing code. This guide will cover installation on Linux (and potentially MacOS), but there are several other ways you can install the SDK.<\/p>\n\n\n\n<h4>The easiest option: Pebble VM<\/h4>\n\n\n\n<p>If you want the super easy option there&#8217;s an Ubuntu linux virtual machine (vm) available with the SDK already installed on it. You can download it <a href=\"https:\/\/willow.systems\/pebble\/vm\/\">here<\/a>. If you have never used a virtual machine before, it&#8217;s like running a computer inside a computer. If you&#8217;re starting from scratch you need to first <a href=\"https:\/\/www.wikihow.com\/Install-VirtualBox\">install virtualbox<\/a>, then <a href=\"https:\/\/willow.systems\/pebble\/vm\/\">download the vmdk file<\/a>, then <a href=\"https:\/\/smallbusiness.chron.com\/open-vmdk-virtualbox-28847.html\">open the vmdk file in virtualbox<\/a>. If you pick this option you can jump straight to the next blog post in this series (<em>coming soon<\/em>).<\/p>\n\n\n\n<h4>The better option: Installing natively<\/h4>\n\n\n\n<p>Although the VM option is quickest, it&#8217;s a little bloated. If you&#8217;re happy copy-pasting commands into a terminal, a native install is the way to go. For this guide I&#8217;ll be explaining how to install on Linux (or MacOS) in the next section. If you want to install the SDK natively on Windows, <a href=\"https:\/\/www.reddit.com\/r\/pebble\/comments\/9i9aqy\/developing_for_pebble_without_cloudpebble_windows\/\">see this link<\/a>.<\/p>\n\n\n\n<h4>Other options<\/h4>\n\n\n\n<p>The above two options are the most straightforward, but here are a few more alternatives. There&#8217;s a <a href=\"https:\/\/hub.docker.com\/r\/rebble\/pebble-sdk\">docker image<\/a> if containers are your thing, an <a href=\"https:\/\/gist.github.com\/zeevro\/ce20d0d74a869d73119e9d1522b7caa7\">install script for debian<\/a>, and even a <a href=\"https:\/\/github.com\/Sorixelle\/pebble.nix\">nix build system package<\/a>. These are all outside the scope of this tutorial but might float your boat.<\/p>\n\n\n\n<h2 id=\"linuxinstall\">Native SDK install on Linux<\/h2>\n\n\n\n<p>For this tutorial I&#8217;m going to cover installation on Ubuntu 20.04, but it will work for any Debian based Linux distro, including Raspberry Pi OS. If you&#8217;re running MacOS the tutorial should serve as a good base guide, but you&#8217;re probably better following the guide available <a href=\"https:\/\/www.reddit.com\/r\/pebble\/comments\/9i9aqy\/developing_for_pebble_without_cloudpebble_windows\/?utm_source=reddit&amp;utm_medium=usertext&amp;utm_name=pebble&amp;utm_content=t3_jlb5rp\">here<\/a>.<\/p>\n\n\n\n<h4>Step 1. Update the operating system<\/h4>\n\n\n\n<p>Before we get started with anything else, lets make sure the operating system is up to date:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt update &amp;&amp; sudo apt upgrade -y<\/code><\/pre>\n\n\n\n<h4>Step 2. Install python2 and python2-pip<\/h4>\n\n\n\n<p>Because the SDK tooling isn&#8217;t python-3 compatible, we need to install the older python2 and associated pip onto our machine.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo add-apt-repository universe\nsudo apt update \nsudo apt install python2 -y<\/code><\/pre>\n\n\n\n<p>Now python2 is installed, we can use the pypa script to install python2-pip.<\/p>\n\n\n\n<pre id=\"block-4a8b1615-b646-45a3-8d46-40ff210799d6\" class=\"wp-block-code\"><code>curl https:\/\/bootstrap.pypa.io\/pip\/2.7\/get-pip.py --output get-pip.py\nsudo python2 get-pip.py<\/code><\/pre>\n\n\n\n<p>Pip will be installed globally. If you want to install it only for your user, run the command without <code>sudo<\/code>. The script will also install <code>setuptools<\/code> and <code>wheel<\/code>, which allow you to install source distributions.<\/p>\n\n\n\n<p>You can verify the install with<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pip2 --version<\/code><\/pre>\n\n\n\n<p>the output from which should look similar to:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pip 20.0.2 from \/usr\/local\/lib\/python2.7\/dist-packages\/pip (python 2.7)<\/code><\/pre>\n\n\n\n<h4>Step 3. Install other dependencies<\/h4>\n\n\n\n<p>We need a few more dependencies, mostly for the emulator:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install wget python-dev libsdl1.2debian libfdt1 libpixman-1-0 npm gcc -y<\/code><\/pre>\n\n\n\n<h4>Step 4. Installing the SDK tools<\/h4>\n\n\n\n<h5>Step 4.1 &#8211; Download and extract the SDK<\/h5>\n\n\n\n<p>Okay. Time to actually install the SDK tooling.<\/p>\n\n\n\n<p>Navigate to your home directory and create a new directory called &#8216;pebble-dev&#8217;.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cd ~\nmkdir pebble-dev<\/code><\/pre>\n\n\n\n<p>Change into that directory, download the SDK tooling and extract it.<\/p>\n\n\n\n<p><strong>(If you are on Linux 32 Bit, or MacOS, read the appendix before continuing)<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cd ~\/pebble-dev\nwget https:\/\/rebble-sdk.s3-us-west-2.amazonaws.com\/pebble-sdk-4.6-rc2-linux64.tar.bz2\ntar -jxf pebble-sdk-4.6-rc2-linux64.tar.bz2<\/code><\/pre>\n\n\n\n<p>Now we have the pebble SDK tooling downloaded. Move into the directory and print your current path<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cd ~\/pebble-dev\/pebble-sdk-4.6-rc2-linux64\npwd<\/code><\/pre>\n\n\n\n<p>the output should be something like<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/home\/will0\/pebble-dev\/pebble-sdk-4.6-rc2-linux64<\/code><\/pre>\n\n\n\n<h5>Step 4.2 Installing the python dependencies<\/h5>\n\n\n\n<p>Install the required python dependencies.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>python2 -m pip install virtualenv\npython2 -m virtualenv .env\nsource .env\/bin\/activate\npip install -r requirements.txt\ndeactivate<\/code><\/pre>\n\n\n\n<h4>Step 5. Add to PATH<\/h4>\n\n\n\n<p>Now the SDK is installed we need to add it to our PATH<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>echo 'export PATH=~\/pebble-dev\/pebble-sdk-4.6-rc2-linux64\/bin:$PATH' >> ~\/.bashrc \n~\/.bashrc<\/code><\/pre>\n\n\n\n<p>The Pebble SDK tooling is now ready to go, verify with<\/p>\n\n\n\n<pre id=\"block-abcd3427-addd-493d-911a-263e3dac5617\" class=\"wp-block-code\"><code>pebble --version<\/code><\/pre>\n\n\n\n<p>If this doesn&#8217;t work, try closing and re-opening your terminal<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h4>Step 7. Install the Pebble SDK<\/h4>\n\n\n\n<p>Now we can install the actual watch SDK. Do so with:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pebble sdk install latest<\/code><\/pre>\n\n\n\n<p>If prompted if you want to enable analytics, press N. If the process crashes or exits at this point, just run it a second time and it will proceed.<br><\/p>\n\n\n\n<p>If this doesn&#8217;t work, try closing and re-opening your terminal<\/p>\n\n\n\n<h2>All systems go<\/h2>\n\n\n\n<p>At this point the SDK should be installed, you can verify by cloning an example pebble project and building it. For example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cd \/tmp\ngit clone https:\/\/github.com\/pebble-examples\/cards-example\ncd cards-example\npebble build\npebble install --emulator basalt<\/code><\/pre>\n\n\n\n<p>If all goes according to plan, the app should build and appear in the emulator!<\/p>\n\n\n\n<p>That&#8217;s it for part 2. Part 3 (coming sometime before Christmas 2022) will dive into how to write your own Pebble app.<\/p>\n\n\n\n<h2>Appendix<\/h2>\n\n\n\n<p><strong>Alternate SDK URLs<\/strong><\/p>\n\n\n\n<p>If you are running 32 bit linux, substitute the wget command in step 4.1 with:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>wget https:\/\/rebble-sdk.s3-us-west-2.amazonaws.com\/pebble-sdk-4.6-rc2-linux32.tar.bz2<\/code><\/pre>\n\n\n\n<p>and if you&#8217;re using MacOS, use:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>wget https:\/\/rebble-sdk.s3-us-west-2.amazonaws.com\/pebble-sdk-4.6-rc2-mac.tar.bz2<\/code><\/pre>\n\n\n\n<p>You will then need to substitute references to <em>pebble-sdk-4.5-linux64.tar.bz2 <\/em>and <em>pebble-sdk-4.5-linux64<\/em> accordingly for the rest of the instructions.<\/p>\n\n\n\n<h3>References:<\/h3>\n\n\n\n<p>Thanks to the following guides &amp; resources which were used to assemble this install guide:<\/p>\n\n\n\n<ul><li><a href=\"https:\/\/www.reddit.com\/r\/pebble\/comments\/9i9aqy\/developing_for_pebble_without_cloudpebble_windows\/\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/www.reddit.com\/r\/pebble\/comments\/9i9aqy\/developing_for_pebble_without_cloudpebble_windows\/<\/a><\/li><li><a href=\"https:\/\/old.reddit.com\/r\/pebble\/comments\/jlb5rp\/pebble_sdk_on_linux_install_tips\/\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/old.reddit.com\/r\/pebble\/comments\/jlb5rp\/pebble_sdk_on_linux_install_tips\/<\/a><\/li><li><a href=\"https:\/\/linuxize.com\/post\/how-to-install-pip-on-ubuntu-20.04\/#installing-pip-for-python-2\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/linuxize.com\/post\/how-to-install-pip-on-ubuntu-20.04\/#installing-pip-for-python-2<\/a><\/li><\/ul>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In part one of this 4 part series we covered the prerequisites you need to know to develop for Pebble watches. Part 2 will cover installing the SDK and Pebble emulator.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[4,12],"tags":[],"_links":{"self":[{"href":"https:\/\/willow.systems\/blog\/wp-json\/wp\/v2\/posts\/555"}],"collection":[{"href":"https:\/\/willow.systems\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/willow.systems\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/willow.systems\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/willow.systems\/blog\/wp-json\/wp\/v2\/comments?post=555"}],"version-history":[{"count":46,"href":"https:\/\/willow.systems\/blog\/wp-json\/wp\/v2\/posts\/555\/revisions"}],"predecessor-version":[{"id":654,"href":"https:\/\/willow.systems\/blog\/wp-json\/wp\/v2\/posts\/555\/revisions\/654"}],"wp:attachment":[{"href":"https:\/\/willow.systems\/blog\/wp-json\/wp\/v2\/media?parent=555"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/willow.systems\/blog\/wp-json\/wp\/v2\/categories?post=555"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/willow.systems\/blog\/wp-json\/wp\/v2\/tags?post=555"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}