Are you ready to expand your iOS app usability? Since its launch in 2015, the Apple Watch, or watch for short, has strived to be a useful companion for iPhones. An Apple Watch application works as an extension of an iPhone app, allowing users to access its main functions just with the watch. Moreover, watchOS, the OS of the Apple Watch, is based on iOS, which makes it easy to learn for iOS developers.
In September 2019, Apple released watchOS 6. One of the greatest novelties of this update is the possibility of creating watch applications independently from iOS apps. Furthermore, this version also includes features like being able to receive push notifications directly on the watch itself, implement sign in more easily, include more services and frameworks, and a whole bunch of other features.
In this article, we’ll show you how to create your first standalone Apple Watch application, the most important things you need to consider before developing an Apple Watch App, and some of the most relevant advantages and differences of a standalone app over an extension from an iOS app.
If you’re already familiar with iOS development, creating a watch app will be really easy, since it’s also based on Swift and the flow is very similar. Nonetheless, due to the watch’s limitations, there are some aspects that you should consider before developing an Apple Watch app, such as the shorter battery life and the smaller screen. For this reason, we recommend to keep the following in mind when designing Apple Watch apps:
So now you know some of the aspects we believe are the most important when designing a watch application. It is time to get our hands dirty and start developing!
Apple has many operating systems (e.g. iOS, watchOS, tvOS and macOS) depending on the devices where the app is going to run. To develop iOS apps for iPhone and iPad or watchOS apps for Apple Watch you need a Mac computer (macOS 10.11.5 o later) running the latest version of Xcode.
Xcode includes all the features you need to design, develop, and debug an app. Xcode also contains the SDK of all the Apple operating systems like iOS, watchOS, tvOS or macOS, which extends Xcode to include the tools, compilers, and frameworks you need.
On Xcode choose Create a new Xcode project and then choose watchOS as a template. As shown in Figure 1, you’ll have two options: the first one is to create an iOS application with an Apple Watch app as an extension; and the second option is to create a standalone Apple Watch app, which is what we want.
If you already have an iOS app with a watchOS app and you want to make it independent, then you should follow these steps:
Once you check the option shown in Figure 2 and run the project, the watchOS app will run independently of the iOS app and you won’t need to run the iPhone simulator, which will provide a much faster debugging experience.
When it comes to design, on iOS apps you can set the position of each element that compose the view by modifying the constraints. There are three main options for setting constraints: 1) You can control-drag between views; 2) you can use the Pin and Align tools; and 3) you can let Interface Builder set up the constraints for you and then edit or modify the results. You can also add constraints to one element that depends on another element in the view, like align center vertically or horizontally, or align top or bottom to the second element in the view.
However, on watchOS apps the design is very limited, there is no concept of constraints and you can’t use coordinates to position the elements. Each element is positioned according to a horizontal parameter (left, center, right) and a vertical parameter (top, center, and bottom). Height and width can be set to a fixed value, related to the container or the content.
Figure 3.1 shows a view containing groups of elements positioned horizontally and vertically. Unlike iOS, watchOS only offers the alignment options shown in Figure 3.2.
The WatchKit life cycle is very similar to the iOS apps cycle. Once you launch the app, the initial interface controller will load to show the views that are implemented on the Storyboard and then the User Interface will be initialized to be shown later. While on iOS apps we use the function viewDidLoad(), on watchOS we should use awakeWithContext() to configure interface objects.
Furthermore, instead of using viewWillAppear() and viewWillDisappear(), on watchOS we use willActivate() when watch view controller is about to be visible to user and didDeactivate() when watch view controller is no longer visible.
WatchOS 6 has many new features that make an independent watch app have an advantage over an app as an extension. We’ll now show you a list of new features on watchOS 6 and how they’re an advantage.
In this article we have learned about some aspects that we must consider before developing a watchOS app, like the screen size, the fact that the Apple Watch has no keyboard for text input, the short battery life and limited storage.
We also learned how to start building an independent Apple Watch app and how to make an existing one independent from the iOS app with the option “Supports Running Without iOS App Installation” on Xcode. So, if you decide to make your watchOS app independent, you would be able to use the authentication services framework to make a Sign In or Sign Up or even use Sign In with Apple for your application. You will also be able to use the iPhone or iPad keyboard for text input on the Apple Watch, so the users can sign in easily.
Finally, with an independent watchOS app, you can implement API requests to manage data directly on the watch app and the user will be able to receive notifications without needing an iPhone nearby. This way, your Apple Watch app will be faster, smoother, and easier to use.