watchOS 2 development tips that iOS developers should not miss

watchOS 2 development tips that iOS developers should not miss

[[152787]]

Highlights

I have only written one article this year, which was in January (Apple Watch: Essentials for WatchKit Applications). I have always wanted to write some articles, but I have not done so, mainly because I am too lazy. I have dug a lot of holes, including articles related to watchOS 2, continuous integration (Java Web, iOS and Android), etc. Maybe I will fill some holes later.

Some things will slowly be forgotten if you put them down for a long time. How frustrating it is.

Let’s talk about some things about watchOS 2 today.

watchOS 2

Apple released watchOS 2 to developers as early as June 9, 2015, but it has not been made available to consumers as of today (October 17, 2015). Currently, only people with an Apple developer account can install it. However, it is already a pre-release version, so I believe it will be available to ordinary consumers soon.

When Apple first launched the Apple Watch, it was actually controversial. Even now, there are still many controversies. Some people are not optimistic about the Apple Watch, saying that its battery life is its Achilles' heel, while others think that its screen limits the application scenarios of the Apple Watch. And so on and so forth, there are all kinds of complaints. Another group of people are very optimistic about the prospects of the Apple Watch and believe that the Apple Watch will change the world again, just like the iPhone released by Apple in 2007.

Personally, I am more optimistic about Apple Watch. Through the following two scenarios, you will find that Apple Watch is very practical:

Payment scenario: When you go shopping in a supermarket and settle at the checkout counter, the traditional way is to pay in cash or by swiping a card. Some people may use mobile payment software to scan the code to pay. However, this is not the only payment method. Even if you use mobile payment, you still need to take the phone out of your pocket. If you use Apple Watch, you only need to raise your wrist and open the payment app to pay. This is not a myth. It can be done with Apple Watch and has been done.

Sports scene: People who run frequently often need to collect statistics of sports data such as timing, speed, and distance during their runs, and provide real-time feedback. Generally, people use sports apps on their phones more often. Every time they check speed, time, etc., they take out their phones from their pockets, unlock the screen, and then check the relevant sports data. Although many mobile phone apps now have voice reminders, the user experience is not very good. If users use Apple Watch, when they want to view sports data, they only need to raise their wrists to view the relevant data, which is very convenient.

Of course, there are many application scenarios that can bring a great experience on Apple Watch, such as reminder applications (weather forecast, call reminders, medication reminders), health applications (real-time feedback of personal health data), etc., which are not listed here one by one.

WatchKit Architecture Changes

Anyone who has developed in watchOS 1 should be familiar with the following picture:

As shown in the figure above, when developing on watchOS 1, the Apple Watch application consists of two parts: the Watch App and the WatchKit extension.

A Watch App is an executable file that runs on the Apple Watch. It includes the storyboard and resource files needed to render the screen.

WatchKit extensions are executable files that run on the iPhone, including logic code for managing the application interface and handling user interaction operations.

For a more detailed look at what’s happening in watchOS 1, see this post on my blog: Apple Watch: WatchKit App Essentials).

Well, in watchOS 2, the architecture of WatchKit has undergone significant changes. Let’s take a look at the following picture:

From the above figure, it can be clearly seen that Apple has moved the WatchKit Extension that originally ran on the iPhone to the Apple Watch. This will directly bring about the following changes: the Watch App that originally only stored some resources and Storyboards, now the business logic part of the program (that is, the code execution part) is also placed in the Watch App. In this way, the program will give users a better experience, and the operation of the Watch App can be completely independent of the iPhone. It is worth noting that Apple Watch 2 also supports WiFi, so Apple Watch can directly obtain some network data through WiFi. And some businesses that Apple Watch cannot handle can be requested to be processed by the iPhone through the Connectivity framework, and the results are returned to the Apple Watch.

[[152788]]

In addition, in watchOS 2, there are more permissions to access hardware resources, such as microphones, accelerometers, crowns, etc. This also brings us developers the most imagination and possibilities when developing.

In fact, watchOS 2 brings many improvements, which I will not introduce in detail here. If you are interested, you can refer to some reference materials provided at the end of this article.

Some things developers need to pay attention to

[[152789]]

In fact, if you have used WatchKit in watchOS 2, you will find that for developers, there is not much change in the development coding in terms of Xcode project structure. Although Apple has made major adjustments to the framework, it has also considered the follow-up costs of developers. Developers' development is basically the same as in watchOS 1. WatchKit App still stores resources and Storyboards, and WatchKit Extension still does the coding of related business logic.

Therefore, when developers follow the watchOS framework, they only need to understand the operating principles of each module, and then the coding will still be the original, familiar flavor.

Of course, there are some things that developers need to pay attention to when developing or migrating to watchOS 2:

For development on migrating to watchOS 2, you can check out the content provided by Apple's official website: watchOS 2 Transition Guide. In addition, this article from springxiao also mentions some development considerations, which is worth reading: Watch OS 2.0 Development Overview.

<<:  What is the reason for the drastic reduction in external recruitment at Tencent, Alibaba and Baidu?

>>:  Expert Interpretation: WatchKit Application Essentials

Recommend

Giant ships also have Iron Man's "armor"? The "secret weapon" in shipbuilding

Did you know that behind those giant ships that t...

Practical notes on Kuaishou, Douyin, and Video Account

Today I will continue to share with you my learni...

How to promote and attract traffic in QQ group?

The QQ platform has huge marketing potential, wit...

So ugly! So smelly! You read that right, I'm talking about orchids

Everyone is familiar with orchids, such as this o...

How to do competitive product analysis report as a workplace rookie!

Recently, a netizen complained to Clippings that ...

Why do others keep making money by selling home appliances?

Don't talk about reason, just tell the facts....

How to push messages to APP (I)

With the development of the Internet and the cont...

8 essential leveraging skills for event promotion!

If there is a way to make an event more effective...

Marine mammals harbor seal

When it comes to harbor seals, do you naturally t...

Tencent Interactive Entertainment Community Product User Growth Formula!

The development of the Internet has entered the s...

Is the constant urge to go to the toilet actually a disease?

One minute with the doctor, the postures are cons...