5

I really don't know how to approach this. I'm creating a keyboard extension and I need to share some data between my application and my plugin. I'm trying to use NSUserDefaults.

I have the following snippet in my application

userDefaults = [[NSUserDefaults alloc] initWithSuiteName:@"group.com.____"];
[userDefaults setObject:@"w/e" forKey:@"mykey"]; //in my app
[userDefaults stringForKey:@"mykey"]; //in my extension

I have created the group ID in itunes connect, updated the application ID for both the app and the extension, I have recreated the provisioning profile and I have add the following entitlements

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
    <dict>
        <key>com.apple.security.application-groups</key>
        <array>
            <string>group.com.___</string>
        </array>
    </dict>
</plist>

everything works great... on the simulator. when I access myKey running the plugin from the device I get a nil object back.

not that, the object userDefaults it self is not nil.

any help?

EDIT the problem doesn't seem to show up if I ask and grand full-access to the plugin. but why would I need full-access to use this functionality? and why do I need it on the device and not on the simulator?

lucaconlaq
  • 1,511
  • 4
  • 19
  • 36
  • I'm testing it on beta5 – lucaconlaq Aug 19 '14 at 10:37
  • I think after setting the object you are not synchronising it. Write [userDefaults synchronize]; after setting object – Chetan Aug 22 '14 at 08:12
  • yes I am. I have paste the code that does it, but I am. I'll edit the question. – lucaconlaq Aug 22 '14 at 15:45
  • Are the identifiers matching in your actual code? Listed here they are not equal : `...SuitName:@"group.com.____` vs `...group.com.___`. I assume just a typo here since you report it works in the simulator alright. – Miles Alden Aug 23 '14 at 04:15
  • @Luka do you get any message to the console when you run the app on a device ? since it is working when you give full-access I would search for any sandbox violation message. – fgeorgiew Aug 24 '14 at 08:52
  • @Luka it seems that this is an open issue which is not fixed yet. I just did some research and you are not the only one who has the problem to make it works on a device: http://stackoverflow.com/questions/24015506/communicating-and-persisting-data-between-apps-with-app-groups/24063144#24063144 OR http://stackoverflow.com/a/24296373/977094 – fgeorgiew Aug 24 '14 at 09:17
  • Is it occurring on iOS8 only? or have you tried it on 7 or below? – Waleed Mahmood Aug 28 '14 at 11:20
  • there are not extensions in iOS7. this is an iOS8-only application. – lucaconlaq Aug 28 '14 at 12:08
  • Hi @Luka you talk about a "grand full-access" but what are you talking about ? I'm really interested about your solution ! Thks ! – FlavienSi Sep 08 '14 at 22:12
  • Hey @Luka have you solved your problem? I am experiencing the same issue. – RadioLog Sep 11 '17 at 10:08

0 Answers0