Apple recently released the long-awaited second iteration of the Apple Watch operating system, watchOS 2. Among several enhancements for users and greater accessibility for developers, the next-generation Apple Watch OS is powered by the ability to run native apps, enhancing functionality and reducing latency.
The first version of the Apple Watch consisted of two bundles: The Watch App comprised storyboards, resource files and other static assets to present the interface; the code that updates the interface, called WatchKit Extension, ran on the iPhone. This separation of code meant apps weren’t really running native on the watch but rather receiving data from the iPhone, which was really running the app. With watchOS 2, WatchKit Extension runs on the user’s watch, making communication between Watch app and extension a lot faster. This also means that the Apple Watch can run independently of the iPhone, breaking a strong dependency that previously existed.
A lot of the existing WatchKit extension code from watchOS 1 should port over to watchOS 2 easily, but there is some reconfigration required, and quite a few elements will require some fundamental architectural changes. For starters, WatchKit Extension requires the watchOS SDK instead of the iOS SDK, but it still relies on the iOS SDK for any tasks not available on watchOS SDK. You also lose the ability to rely on shared group containers for exchanging files, instead fetching files required wirelessly or via the cloud/network.
The latter is quite interesting, in that watch apps can now pull information from the network directly, without needing the iPhone. Both bundles reside on the watch itself, meaning apps no longer always require to make the roundtrip via Bluetooth, and rather can interact with the network directly. (source: Apple)
So, the extension must use watchOS SDK, not iOS SDK. Any features not yet available on watchOS will require the iPhone to handle the task. Data and files can now be stored directly on the watch, and those that are not will need to be retrieved from either the network or cloud.
With a brief overview of the architectural differences, the question developers should ask is: Should I be migrating my watchOS 1 app to watchOS 2?. To help people make the decision, Apple has provided a checklist of questions for developers to answer:
- Does the App rely heavily on iCloud? - Because watchOS 2 no longer works with iCloud, synchronizing between devices has fundamentally changed. Developers will need to develop and manage synchronization wirelessly between devices.
- Does the app rely heavily on data from its iOS App?: If an app relies heavily on transfering information from its companion iOS app, developers will need to once again orchestrate and manage local and remote versions of data. Data is not backed up on the watch, so developers must remember to constantly backup to iOS.
How do I migrate my project from OS 1 to OS 2?
Apple provides excellent documentation that outlines what’s needed for developers to migrate over to watchOS 2. Developers will first need to configure their Xcode project and view the watchOS SDK framework technologies available in order assess what can be done on the watch--and what has to be done on the companion iOS app, before being passed to the watch.