WatchKit tutorial: Maps on the Apple Watch

We finally have a release date for the Apple Watch! I’m looking forward to building apps with the actual device, but for now the simulator will just have to do. There’s an interesting new watch simulator called Watch Sim that will let you evaluate your Apple Watch app in real size on an iPhone or iPad, but it’s a bit pricey. If you’re not planning to get a watch though, $9.99 is a great bargain (but would you really be making Watch apps without owning an actual watch?). I find that Bezel is a pretty good substitute, but there’s no physical interaction (it’s still only on your computer screen).

Onto the tutorial!

Apple Watch Maps

If you’ve been following along, this next tutorial should be pretty simple compared to the last couple that I’ve made. We’ll be looking at displaying a map on the Apple Watch and setting both native and custom markers on it.

Map Interface
The downside is that that’s pretty much all you can do at this moment (as of the iOS 8.2 release). Users can’t even interact with these static maps – once the user taps on it, it will open up the default Apple Maps app. You can read more about map capabilities on the Apple Human User Interface Guidelines.

As always, I’ve provided all of the project code on GitHub. You’ll also need some image files – download the zip file here. Let’s get started.

Continue reading

WatchKit Tutorial: Communicate from Parent App Back to Watch via Reply

Note: this will be a continuation from my last tutorial on WatchKit – Send Data to your Parent iOS App. If you haven’t done it already, I suggest you start there first.

WatchKit Updates

It’s been about a month since my last WatchKit tutorial and we’ve had 2 new beta releases for iOS 8.2, including a few changes for WatchKit. Here’s the release notes for iOS 8.2 beta 4:

watchkit iOS 8.4 beta 4 release notes

WatchKit still has pretty limited functionality and there haven’t been many new changes – it’ll be interesting to see what kinds of apps people create once it’s live. Looking back on the Apple keynote where they announced the Apple Watch and showed all the cool tricks like being able to send your heartbeat to someone else, I feel a bit cheated as a third-party developer. So far, we don’t have access to any of these interesting features. It’s like when a movie trailer shows all the cool parts of the movie, and the movie itself is pretty lame.

Reply Back to Watch app

Counter Reply

Now, to get down to business – I’ve added on to my original tutorial that allowed you to send data to your parent iOS app from the watch. We’ll be exploring replying back to the Watch app from the parent iOS app. This is useful for cases where you may want to update the UI of your Watch app or execute some code after your iOS app receives data from the Watch. In this case, we’ll be showing the user a “Saved” notification indicating that their save to the iOS app was successful.

You can see the finished project for this tutorial here on Github.

Modify Watch Storyboard

To get started, bring up the finished counter project from the last tutorial. If you haven’t gone through it yet, you can grab it here from Github.

Continue reading

WatchKit Tutorial: Send data to parent iOS app

WatchKit beta 2 was just released as a part of the iOS 8.2 developer seed. One of the best new additions to the SDK is the ability to communicate back to the iOS parent app from the WatchKit extension. This allows us to essentially “close the loop” and pass information from the watch to the watch extension and to the iOS parent app that supports it.

I created a simple counter app for the watch which saves its count values back to a simple iOS table view app when the user hits a Save button. This tutorial will demonstrate how to transfer data to the parent iOS app from the watch extension. See the finished project on GitHub.

watchkitdemo

Now before you jump into this tutorial, I highly recommend that you read Natasha’s Hello World WatchKit tutorial first. This tutorial will assume that you’re already a little bit familiar with WatchKit (and iOS development in general).

Continue reading