Apple Watch, WatchKit First App Setup – Hello World
Setting up a watch kit app for the Apple Watch can be confusing at first – it isn’t exactly straight forward, even when you have it setup the way it is setup can be a bit confusing! This post will cover the setup of your first watch kit app and also explain the reason it is setup in a certain way.
First of all to be able to setup a watch kit app at the time of post you will need to use XCode 6.2 beta upwards. It can be downloaded from: https://developer.apple.com/xcode/downloads/
Note you will need a free Apple developer account (Note the free, Apple currently does not restrict it to paid developer accounts)
Once you have this launch XCode and lets setup our first Apple Watch App! The first step is to create a new XCode project is to load up XCode and choose “Create a new XCode project”. Make sure iOS, Application is selected on the left side. Then on the right side select “Single View Application”. This will create a blank iPhone App with a white screen. Go next and name our project “Hello World”.
Now with that created lets add the watch kit extension to our app to support the Apple Watch! Go File, New Target. Select iOS, Apple Watch. and choose Watchkit App.
Go next and leave the option’s on the next screen as they are and go create. Notifications and Glances with be covered in a future post. You will have noticed two folders have been created now. One is the Hello World Extension and the other is the Hello World App.
Basically for a watch kit app, the views such as buttons, tables and images are stored on the Apple Watch. The code that runs these controllers and models is stored on the iPhone itself. Basically when you click on a button on the Apple Watch it will run the code on your iPhone over bluetooth, once the code is run your Apple Watch will update it’s views based on the code. This is all done extremely fast in the background so you won’t notice it! The image below outlines how this works:
Now we have that done, open up the HelloWorld Watchkit App and select the Interface.storyboard. From the bottom right drag a label onto the Watchkit App so it looks like the following:
Now click run your app from the top left, making sure “HelloWorldWatch Watchkit App” is selected. This will run your app on the Apple Watch Simulator.
Congratulations, you have setup and run your first Watchkit App!