 Watch App and Core Data

This post will be a little more technical than most on this site. I wanted to explore how to create a Watch App which shares data with its companion Phone App via Core Data. Though this seems reasonably straight forward to achieve, I didn’t see a lot of info on the developer forums. Furthermore, there were a few tricks to getting it to work that I felt were worth sharing.

Below, I cover Core Data integration with a Watch App at a high level and in the linked video and Github repository I cover the approach in full detail. I put this together in an evening, so design may be a little basic, but should provide a good jumping off point.

 High Level Steps

  1. Create a Core Data app using the Master/Detail iOS template
  2. Add a Watch App Target
  3. Add a shared App Group container in the Capabilities area of the project. Add the same container for each of the following:
    • iPhone App
    • WatchKit Extension
  4. Update the location of the Persistent Data Store to point to the App Group
  5. Create a Cocoa Touch Framework for the shared code that accesses the Core Data Store
  6. Move core data access code into the framework; make classes and methods public
  7. Build Watch App UI that consumes Core Data via the shared code in the Framework
  8. Build and run!

 Video Walkthrough

If you’d like to watch me create this app in 10 minutes, then check it out here.

 
140
Kudos
 
140
Kudos

Now read this

AirPods. Delightful innovation.

The AirPods seem to be the one recent product release from Apple which isn’t receiving a slew of negative attention. Though I’m not as bearish on Apple’s recent releases, I would agree that the AirPods are the strongest, and most... Continue →