How To Create and Run a Apple WatchKit Application

168 0

Getting started with the new Apple WatchKit Beta could be frustrating if you eagerly downloaded the Xcode 6.2 Beta and wondered how you create a new WatchKit application. Let me show you the simple steps to get started as they might not be obvious.

First you start by creating a new Xcode project (more detailed explanation on my post here), choose ‘iOS Application’ and ‘Single View Application’. You do this because there is no project type for a WatchKit application directly, what you need to do is create a standard iOS application and then create a new ‘target’. Make sure you also select ‘Swift’ for the language, you can leave ‘Devices’ to ‘Universal’, again there is no direct selection for WatchKit.

Xcode 6 - new iOS application window

Now the fun begins, you start with a standard iOS application. Go up to the ‘Editor’ menu and select ‘Add Target…’.

Xcode - Editor Menu

On the sheet that appears in Xcode you should now see on the left side list under ‘iOS’ the option for ‘Apple Watch’, select it and there should appear the magical ‘Watch App’ on the right side, just click ‘Next’ and leave all the details as Xcode has filled them in for you (at least for this basic start). Just click ‘Finish’.

Xcode - Apple Watch App Sheet

Xcode - WatchKit App Finish Sheet

You will now see some new folders appearing in the project file listing on the left side if you have the panel open.

Xcode - WatchKit New Files list

Open the folder that ends with ‘Watch App’ in my case it is called ‘WatchKit Example Watch App’, in there you will see a familar storyboard file, go ahead and open it … voila the new Watch App interface is ready to be built.

Xcode - WatchKit default storyboard

In this post we will not get into editing our application, I want to take you straight to getting it to run in the simulator so you can share in the fun and excitement of this new era of apps! There are a couple of extra steps here (at least in the current BETA as of this post) to get it running with the right display so stick with me.

First, build and run the app as normal, the application should appear in the iPhone simulator. After the application has run stop it back in Xcode. Now go to the simulator and look for the ‘Hardware’ menu item, click on it and then choose ‘External Displays’, here you should see listed the Apple Watch. Select one, I chose ‘Apple Watch – 42mm’.

iOS Hardware External Display Menu

You should see a new window appear which will act as the watch display.

Apple Watch 42mm - 312 x 390

Back in Xcode click on your application active scheme (in my case ‘WatchKit Example’) in the toolbar on the left just after the play and stop buttons.

Scheme selection

When you click on the toolbar icon a drop down list should appear showing the target you created earlier when creating the WatchKit target, select it (in my case ‘WatchKit Example Watch App’) and leave it pointing to iPhone 6.

Xcode 6 application scheme dropdown.

Now run the application again and this time it should appear in your watch simulator window! Since we have not added anything there is not too much to see, but the point is you made it to running your new WatchKit application, congratulations!

Apple Watch 42mm - 312 x 390 2