Apple announced a major update to watchOS 2 today that will be available with iOS 9 this fall. We've gone through the official Apple documentation, all of the headers and code provided in Xcode 7, and summarized everything for you so you can quickly skim what's coming up.
The WatchKit Extension now runs on the Apple Watch
In watchOS 1, the WatchKit extension ran as an extension of your iOS App. In watchOS 2, it runs natively on the Apple Watch. This is great because you get native performance without the slow back-and-forth communication over Bluetooth for every UI interaction.
There is a downside though–current WatchKit extensions enjoy the use of every iOS API, whereas the new watch OS 2 apps have access to a subset of APIs available only to WatchKit. For example, if your extension depended on CloudKit, you can't use it directly on the Watch and will have to contact the parent iOS app if you want to continue using that functionality.
Watch Connectivity is for synchronizing the iPhone and Watch
Now that the watch app runs on the actual watch device, synchronizing data and state between the iPhone and watch is a little trickier. Apple has added Watch Connectivity with the WCSession
class to facilitate communication between the two devices.
You bundle watchOS 1 & 2 apps in the same app
Apple will allow you to continue to bundle the old WatchKit extension code for watchOS 1 users in addition to shipping new code for watchOS 2. If you do this, sharing code might be tricky as different APIs are available between the two and it doesn't appear as though embedded frameworks will work on the watch.
WKExtensionDelegate is the AppDelegate for WatchKit
One of the annoying things in watchOS 1 was how difficult it was to track app lifecycle changes. Now you simply implement WKExtensionDelegate
similar to how you implement AppDelegate
on iOS. There's a simplified lifecycle, with three states: Not Running, Inactive and Active.
You can add Complications for your app to the watch face
If you implement CLKComplicationDataSource
from ClockKit, you can set up complication information. You provide a timeline, where you describe the various changes to your complication throughout the day, as well as an interval for when ClockKit should refresh your complication. There is also a high-priority push-notification that you can use meant for updating the Complication in real time.
Check out our guide on Writing a WatchKit Complication.
You can play Video and Audio content on the watch
For embedded video and audio in your UI, use WKInterfaceMovie
. To present this in a new controller, use presentMediaPlayerControllerWithURL:options:completion:
. If you want to play extended content that continues playing even when your app is inactive, use WKAudioFilePlayer
and set up the audio value in UIBackgroundModes
in your Info.plist
.
Audio plays directly on the watch, prioritizing the Bluetooth speaker, but will also use the built-in speaker if a Bluetooth speaker is not available.
You can record audio with the microphone
It seems you can only do it through Apple's stock audio recording controller, calling presentAudioRecordingControllerWithOutputURL:preset:maximumDuration:actionTitle:completion:
. There doesn't seem to be a way to record audio and process realtime audio or record audio inline or using a custom controller or UI.
You can use the Taptic Engine to provide haptic feedback
WKInterfaceDevice.playHaptic()
will provide haptic feedback. You can pick from one of the choices in the WKHapticType
enum. We didn't find a way in the documentation or header files to define custom haptic feedback.
Check out our guide on Writing Haptic feedback on the Taptic Engine.
Digital Crown Access
The WKInterfacePicker
handles digital crown access. You can have a List UI, a stack of cards that animate, or an image sequence that responds to the digital crown. We didn't find a way to read raw delta values from the crown in the current API, which may be useful for game developers.
Check out our guide on coding your own WKInterfacePicker
: Using the Digital Crown.
Access to Sensors
Opening up Xcode 7, we were able to import CoreMotion
and instantiate a CMMotionManager
in a test WatchKit Extension project. This appears to work exactly like in iOS. We assume that heart rate and step data are also available through the HealthKit framework.
HealthKit, HomeKit, PassKit, CoreLocation, CoreGraphics
In Xcode 7, we were able to import and instantiate objects from all of these libraries from within our WatchKit extension project, so we assume that these work just as they do from iOS. CoreAnimation did not appear to be available.
Xcode Simulator
The Xcode simulator now fully supports the watch. This means that you can test glances, notifications, watch complications and so on. You can also debug and run the watch and device simulators simultaneously which was not possible in watchOS 1 simulators.
In addition, the Hardware menu has added "Simulate Touch Pressure" with an option for Shallow Press and Deep Press. Scrolling your mouse-wheel simulates digital crown movement, and pressing ⌘⇧H simulates pressing the crown in.
To be continued...
As WWDC unfolds, we'll update the information here with corrections and the latest information as Apple provides it. All in all, watchOS 2 is an extremely exciting improvement for developers, and we can't wait to update Chairman Cow to the new features, and stay tuned as we are determined to bring you world class watchOS 2 apps and games this fall!
Edit: 6/8/15 Added information about recording audio/microphone.