Our app is now available for Apple Watch and we tried to keep things simple:
The shopping list is pushed to the Apple Watch app. So you can tick off the items on the watch while walking through the grocery store. The order of the items is taken from the main app, so you can optimize the path through the store.
You can defer items to the end of the list and … that’s it.
The app features a glance which acts as a quick start and shows the number of items and the top items to buy.
It’s on my list
Developer lessons learned
While we created the Watch app, we learned some lessons about WatchKit for watchOS 2.0, iOS and swift. Apple provides great guides and documentation, so building a Watch app is fairly easy and straight forward. As always, one should read the documentation thoroughly. Beyond this, we found following items worth mentioning. They might help you to avoid some pitfalls during coding your Apple Watch app.
No Translation in Watch companion app
We tried to localize the app name displayed within the Watch companion app. But it seems, it is stuck to the base location. You might follow this stackoverflow post to know more.
And as a bonus, currently you cannot programmatically open the Apple Watch companion app from your iPhone app. Again, see stackoverflow.
Simulator and background tasks
Testing with background task has some issues in the simulator. The remaining-time-in-background was not working out right, but there were no issues on actual devices. Our app even uses
NSTimer in background, which is possible, as long as you stick to the rules of background processing.
Bitcode is mandatory
For watchOS and tvOS apps, bitcode is required
In general this is not issue, but we are using the Dropbox SDK which was not updated to support bitcode. So we ended up including the Dropbox SDK source and compiled it on our own – which was fairly simple and straight ahead. But please make sure to add the Dropbox URL schema
For iOS 9+ the source code for your Info.plist file should now have the following:<key>LSApplicationQueriesSchemes</key> <array> <string>dbapi-2</string> </array>
Callbacks to WCSession are not dispatched to main thread
All callbacks to
WCSession do not run in the main thread, so you might need to dispatch your work accordingly. Also this might cause timing issues, because as soon as a
WCSession exists, callbacks might be triggered – even if your app was just launched in background and your app start lifecycle is still on its way.
transferUserInfo: callback has an error exit
WCSessionDelegate docs. We did not realize, that there is an error callback for
transferUserInfo calls. We thought this is a fire&forget call, similar to
updateApplicationContext, but we were wrong.
Context Menus trigger WKInterfaceController Activation Events
We did not expect this, but showing a context menu actually will result in your WKInterfaceController
Fresh install might kill initial Watch app start
A fresh install of our watch app would not start while the Watch Companion App is open and active. No crash report was created, but it looked like the initial start just took to long and the system killed the process.
The culprit was, that we initialized some properties when the first Interface Controller was loaded. Just using swifts
lazy keyword saved us
lazy var communicationManager = CommsManager()
Glances do not get lifecycle methods
This is well documented, but you might still stumble over it.
Have fun and be awesome!