I've seen a couple of questions on this, and tried all the answers provided, and this still isn't working for me.
I'm trying to share several small pieces of data (Strings and BOOLs) between my iPhone App and its WatchKit extension. (If it makes any difference, the info is being read by the GlanceController of the WK app)
Via the Developer site I created an App group (group.com.theYawns.Sorcerers-Apprentice). If I look at 'App IDs' there I appear to have two identical IDs for my app (com.theYawns.Sorcerers-Apprentice) plus one for the extension (com.theYawns.Sorcerers-Apprentice.watchkitextension). Each of these has 'App Group' enabled (for both Development and Distribution) and the app group is selected if I edit the App ID.
I've turned on 'App Groups' in capabilities for both the App and the Extension. A concern I have it that periodically -- several times a day but not every build -- if I go in and look at the Capabilities tab, I have a red exclamation point saying 'Add the App Groups' entitlement to your entitlements file. If I look at the entitlements file, the entitlement is there, and if I click 'Fix issue', the red exclamation point changes to a checkmark. But the fact this needs to be done multiple times per day concerns me that something is amiss.
I've refreshed my provisioning profiles under XCode preferences many times, and while I don't see an App Groups icon under entitlements, if I hover I do see app groups in the tooltip that pops up.
In both my app and extension, I get a reference to the user defaults via
NSUserDefaults *sharedAppDefaults = [[NSUserDefaults alloc] initWithSuiteName:@"group.com.theYawns.Sorcerers-Apprentice"];
I've also tried adding a [sharedAppDefaults synchonize]
after each write and before my WatchKit attempts to read, just in case things weren't being flushed out. (Didn't make any difference).
My WatchKit extension bundle id is different from my iPhone App bundle id, which is one of the answers I saw on a different thread.
I've also added an NSTimer to refresh the glance every 10 seconds, so if there was a timing issue with picking up the changes, I would expect it to resolve itself after an update cycle or two, but it does not.
Really stumped ... seems others have had their issue resolved by answers from the other threads but none have worked for me.
Other threads I've searched include: