app group container path is different on watch app

Hi,

I wanna use app group shared container for both iphone and watch.

The problem is that when I call

NSFileManager.defaultManager().containerURLForSecurityApplicationGroupIdentifier(appGroupID)!


this API, it returns different path depending on which device I call it.

For example,

On iPhone side, it gives this URL:


file:///Users/****/Library/Developer/CoreSimulator/Devices/C2A842DA-717A-47CC-A156-A88443E5D463/data/Containers/Shared/AppGroup/04ADFA9D-3D5D-4C2B-8C71-1F910FF23E28/


On the other hand,

On Watch side, it gives:


file:///Users/*****/Library/Developer/CoreSimulator/Devices/9EE19C73-9785-4560-AAB4-8B9A3D09B4A8/data/Containers/Shared/AppGroup/BD18BBF9-E665-4E39-9110-674E70194177/


I think each device generates shared container on its device. What can solve this problem?

Accepted Reply

If you're using watchOS 1 you need to ensure that both the iOS app and watch extension have a provisioning profile configured for App Groups, and configure the App Group name in the developer portal (where you set up provisioning profiles).


If you're using watchOS 2 you can't use App Groups to share files since the watch extension runs on the watch, not the phone. The WatchConnectivity API needs to be used to coordinate data transfers or sharing of app data.

Replies

Did you solve this? I'm experiencing the same problem on the final XCode 7.0 (7A220)

If you're using watchOS 1 you need to ensure that both the iOS app and watch extension have a provisioning profile configured for App Groups, and configure the App Group name in the developer portal (where you set up provisioning profiles).


If you're using watchOS 2 you can't use App Groups to share files since the watch extension runs on the watch, not the phone. The WatchConnectivity API needs to be used to coordinate data transfers or sharing of app data.

As hackinicity said, you can't use AppGroup to share files anymore...

I'm super confused.. people are saying you can't use App Groups anymore but on this thread people are saying they can read the Settings preferences on watchOS 2 without any WatchConnectivity code.


Even on the documentation page for Settings it gives you instructions on setting up an App Group so the watch can read the preferences.


I've been trying to figure this out for days and still unclear.

You can use an App Group on watchOS 2, but it will not sync with an App Group on iOS. They will be independent — the watch app and phone app won't share data — so you need to manage the syncing yourself.


There is one exception, though, and that is the settings bundle. That will be synced from iPhone to Watch automatically.

It is not syncing automatically for me as you claim for the Settings bundle. I set up everything correctly, but I try to read the settings from the watch bundle and it doesn't get the data.