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.

Stephen Johnson
  • 5,293
  • 1
  • 23
  • 37

2 Answers2

6

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.
Community
  • 1
  • 1
spybart
  • 2,583
  • 3
  • 22
  • 33
-1

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.

CarlosGz
  • 396
  • 2
  • 6
  • So does this mean I can't simply use the settings in the iPhone Watch app? If I did use the settings in the iPhone Watch app I would have to transfer those values to my watch app via WatchConnectivity the next time the user opened my iPhone app? – Stephen Johnson Aug 04 '15 at 14:57
  • 1
    Yep, but not necessarily when the user open the iOS App, you can transfer data in background using WatchConnectivity, so when the user opens the iOS App, the data should be there yet. – CarlosGz Aug 04 '15 at 15:04
  • Ahh, yes so the watch app could ask the iPhone app for the settings. Thanks for your help!! – Stephen Johnson Aug 04 '15 at 15:10
  • 1
    I have problems reading the settings bundle data even when running from my phone. Any help? – fredpi Aug 24 '15 at 07:57
  • You shouldn't, but you always can fill an SO question setting more details about your issue – CarlosGz Aug 24 '15 at 08:20
  • Hey, I posted it here: http://stackoverflow.com/questions/32177834/cant-read-watchkit-settings-bundle-from-iphone-app. I would be fine if you could have a look at it. – fredpi Aug 24 '15 at 08:38