Apple WatchKit tutorial - the first look
Picture credit: iStockPhoto
Yesterday, Apple released WatchKit, the SDK that allows apps to be created for its upcoming Apple Watch. I grabbed Xcode 6.2 Beta (Apple Developer Program membership is required), and decided to give building something a go. Here’s what happened.
There are three types of Apple Watch experiences that can be built today: Watch Apps, Glances, and Notifications. With this iteration of the SDK an iPhone is required, but the ability to build standalone watch apps is supposed to arrive next year.
Once I got the new Xcode up and running, I really just wanted to create a “Hello Watch” app to get a feel for things. Rather than risk compatibility issues with older projects, I started with a new project (File->New->Project). I picked a Single Page Application and gave it a generic name.
So far, things were going pretty smoothly. I decided to run the app to see what would happen. I chose the “Watch App” target and clicked “Run” to launch the Simulator, but was initially disappointed that only the iPhone Simulator launched! I assumed that since I was running the Watch App target, the Apple Watch simulator would automatically launch. Plus there was no Apple Watch simulator listed in the hardware list.
The documentation isn’t explicitly clear about this (it is buried in the video, about 20 minutes in), but there are two Apple Watch simulators representing the 38mm and 42mm models. To use them, open the iOS Simulator and click Hardware->External Displays->Apple Watch.
So it was cool to get the simulator running, but a true Hello World isn’t complete without some form of text on the screen. If you’ve worked with Xcode much before, you know that Storyboards are an easy way to create a basic UI. This paradigm translates to Apple Watch apps.
In the “Watch App” group, there’s an Interface.storyboard that houses the Scenes for the Interface Controller and Notification Controller (and Glances, too, which we’ll cover in another post). I added a basic label by dragging it onto the storyboard for the main interface, and there it was, my first Apple Watch app.