Join Simon Allardice for an in-depth discussion in this video Core concepts, part of Developing for Apple Watch First Look.
- I'm going to begin with five facts. Five things that are true about Apple Watch development right now. We're not getting into syntax yet, this is high level information that I just wish someone had straight away told me in my first five minutes of Apple Watch development. If you've been exploring Apple Watch development, you may know some of these already, but they'll set the stage for what we're about to do. Fact number one, there is no Apple Watch project template in Xcode. You can't go into Xcode and just make an Apple Watch app.
That was something a lot of people kind of expected. Apple released the first beta for Watch kit at the end of 2014. Lot's of us downloaded it. We installed this new version of Xcode, we opened it, and the first thing we all did was click on create new Xcode project and say, okay, where's the Watch project? Well you can look for it all you want, it's not there. There is not Watch project in Xcode. Instead you must begin with an iPhone app, a regular Xcode iPhone project. Either a new one, or one you already have and then add a Watch app to that as part of an existing iPhone project.
But why and what does that mean? Fact number two, your Watch app requires a paired iPhone. Okay, this might not seem like news, but Simon, everybody know that if you have an Apple Watch you need an iPhone to go with it. That's not what I'm talking about here. You see there are Watch apps that happily run all by themselves. You can go out for a jog and leave your phone behind or even turn the phone off and you'll still be able to play music, use the work out app, use Apple Pay, view photos. Those apps are Apple's Watch applications, not ours.
We are third party developers and every third party app requires the phone connected to be able to run at all. Why? Because all our Watch apps are in two parts. A part that resigns on the Watch and a part that resigns on the iPhone and it's the part on the iPhone that does all of the work. That's fact number three. The code you write for your Watch app, that swift or that objective, see, it's going to run on the iPhone not on the watch. Let me say that again. The code that your write here, all your logic, all your behavior, is going to run on the iPhone not on the Watch.
The only thing that's installed on the Watch is your user interface. Your storyboards with your buttons, labels, switches, tables, any image assets you need, like icons, graphics, or animations, the user interacts with that on the Watch and it will communicate with and use your iPhone to do any processing that needs to happen. This is an intentional limitation right now. As a third party developer, with this initial release of Watch kit, we are not able to create a standalone, self-contained, native Watch app.
That's true today, it may... That's right, I wasn't going to say that anymore. So you might wonder, what are we doing here? Are we creating a Watch app that has an iPhone piece or are we creating an iPhone app with a Watch piece? Well fundamentally it is an iPhone project with added Watch support. Even Apple's initial Watch kit pages on the web had that phrase. You weren't being told to make a Watch app, you were being told to get your iPhone app ready for Apple Watch. That's the right perspective.
That might not be the way you are thinking about things. You're watching this course thinking, hey, I've got a great idea for a Watch app. Excellent, but you're still going to have to begin by making an iPhone app. Fact four, because all our code runs on the phone, we don't have access to special hardware on the Watch, like the heart rate monitor. Direct access to the tap-tick engine, we'll be able to change the behavior of the digital crown. We are working in a much more constrained environment and Apple are not letting us have access to those things yet.
So one, there is no Watch project. We add Watch support to an iPhone project. Two, our apps need a connected iPhone to run at all because three, our code is going to run on the iPhone, and because of that four, we don't have direct access to the Watch specific hardware. Fact number five, despite all of these initial limitation there is still a lot we can do. Let's make our first Watch app.
- Core concepts and architecture
- Creating a user interface for Apple Watch
- Handling scrollable content
- Creating menus, buttons, and groups
- Using control and lifecycle events
- Creating and populating Apple Watch tables
- Building glances and notifications