Video Tutorial: WatchKit Part 12: Sharing Data

In this WatchKit tutorial learn how to use a shared container to share data between the iOS app and the WatchKit extension. By Mic Pringle.

Leave a rating/review
Save for later
Share

Contents

Hide contents

Video Tutorial: WatchKit Part 12: Sharing Data

1 min

Challenge

Your challenge is to keep watching this video series and find your challenge in the next video!

  1. Update all three targets to use your own Team
  2. Create an App Group and register it with both the iOS app and the WatchKit Extension, as shown in the video
  3. Update CoreDataStack.swift to use the App Group you created
  4. Update the Bundle Identifier of all three targets
  5. Open the info.plist file of the WatchKit Extension, find the NSExtension\NSExtensionAttributes\WKAppBundleIdentifier key and update that to match the bundle identifier of your Watch app
  6. Open the info.plist file of the Watch App, find the WKCompanionAppBundleIdentifier key and update that to match the bundle identifier of your iOS app
Note: Please note that the completed project we’ve provided will not run out-of-the-box. You will need to make the following changes before you Build and Run:
  1. Update all three targets to use your own Team
  2. Create an App Group and register it with both the iOS app and the WatchKit Extension, as shown in the video
  3. Update CoreDataStack.swift to use the App Group you created
  4. Update the Bundle Identifier of all three targets
  5. Open the info.plist file of the WatchKit Extension, find the NSExtension\NSExtensionAttributes\WKAppBundleIdentifier key and update that to match the bundle identifier of your Watch app
  6. Open the info.plist file of the Watch App, find the WKCompanionAppBundleIdentifier key and update that to match the bundle identifier of your iOS app

Download lecture slides

Download demo starter

Download demo finished

View previous video: Part 11: Page-Based Interfaces II

View next video: Part 13: Glances

Errata

  1. The video states that containerURLForSecurityApplicationGroupIdentifier(_:) was introduced as part of iOS 8. The method was actually introduced as part of iOS 7, which means you could use App Groups prior to App Extensions and WatchKit
Mic Pringle

Contributors

Mic Pringle

Author

Over 300 content creators. Join our team.