Stephen Johnson
Stephen Johnson

Reputation: 5121

Unable to get values from settings bundle in watchOS 2

I have a settings bundles that I use with my watch app. I am migrating my app to watchOS 2. Does anyone know how setting bundles are supposed to work? Does the iPhone transfer the values to a the standard user defaults or to a user defaults with a suite name for a shared app group? I can't get either to work and I can't find any documentation on how setting bundles are supposed to work with watchOS 2.

Upvotes: 2

Views: 592

Answers (2)

spybart
spybart

Reputation: 2593

The accepted answer is wrong. You can use Shared App Groups for the Settings bundle on WatchOS 2 and access the values via NSUserDefaults. No Watch Connectivity required. It is just tricky to set up and the official documentation is missing crucial info.

Recently discovered how to do it in my question here.

The 2 important points are:

  1. You need to enable Shared App Groups on all 3 targets (iOS app, Watchkit app, WatchKit extension)
  2. It only works on the real device, not simulator. You might need to remove the app from both devices and reinstall to have it start working.

Upvotes: 6

CarlosGz
CarlosGz

Reputation: 396

In Watch OS 2.0 since the Watch App extension is in the Apple Watch (not in the iOS App as in Watch 1.0) you can't transfer data through user defaults, so you should use instead WatchConnectivity. If you have a settings bundle or a framework and you want to use it in the AW App extension and in the iOS APP, you should import it in every target of your project.

Upvotes: -1

Related Questions