dwyl / learn-apple-watch-development

:green_book: Learn how to build Native Apple Watch (+iPhone) apps from scratch!
55 stars 5 forks source link

Developing for Apple Watch (Apple Guide) #17

Open sohilpandya opened 7 years ago

sohilpandya commented 7 years ago

Apple has built a guide: Developing for Apple Watch

My plan is to go through the documentation and make notes as I read along so that we can all gain a better understanding of how to go about developing for Apple Watch, which will eventually help with getting v0.1 off the ground #15

sohilpandya commented 7 years ago

Introduction to developing for Apple Watch

There are three distinct UI's that need to be looked at:

Watch app can live inside the corresponding iOS app.

App Target Structure

As shown in the structure above: screen shot 2016-12-01 at 16 25 42

Watch App Architecture

screen shot 2016-12-01 at 16 34 59 Watch App bundle

Communication between your WatchKit Extension and iOS app is possible through the Watch Connectivity Framework

The WatchKit extension has an extension object - WKExtension and a corresponding delegate object to manage behavior that is central to your app.

Managing the Watch App Life Cycle

screen shot 2016-12-01 at 16 50 18

When the Watch app is launched, the methods of WKExtensionDelegate protocol are called for each transition phase:

Note
sohilpandya commented 7 years ago

Reading through the WatchConnectivity Introduction by Natasha the Robot

I found a link to a tutorial which would guide a user through how to use watchConnectivity, here but unfortunately, it's not compatible with WatchOS3 😢

This has lead me into doing some more research and trying to find out how exactly one would go about implementing this in the latest OS. Issue is with implementing a new mandatory method called session:activationDidCompleteWithState

😢 😢 😢 😢

sohilpandya commented 7 years ago

An update for the day, I've been trying to get this supposedly simple feature where selecting a button on the watch would change the label on the phone. I have been following this tutorial http://kristina.io/watchos-2-tutorial-using-sendmessage-for-instantaneous-data-transfer-watch-connectivity-1/ which would allow us to transfer some data from the watch to the phone.

Simulator problem I've taken a step closer to achieving that goal, but now I am unable to get the watch simulator to recognise the watch app. :( solution Change the active scheme from just app to apple watch app + phone app as seen below

screen shot 2016-12-02 at 17 58 19

I've still not managed to get the message between the two devices, I'll leave this as is now and look at it with fresh eyes next week. (or perhaps the weekend. 😄 )

sohilpandya commented 7 years ago

Update from Monday morning session 🔍

I hit a wall on Friday, where I was unable to get the connection to work. After some futher research and looking into some code from the tutorial listed above, I've managed to get v0.1 up and running 🎉

If a user selects the button on the watch, they are able to see the text label change on the iPhone.

ezgif com-video-to-gif

My next steps are to create a short tutorial on how to do the following.

nelsonic commented 7 years ago

@sohilpandya amaze! 😍