NSUserDefaults with SuiteName runs on the simulator, but not on the device

I really don't know how to approach this. I am creating a keyboard extension and I need to share some data between my application and my plugin. I am 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 created a group id in itunes connect, updated the application id for the application and extension, I recreated the provisioning profile, and I added the following rights

 <?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 fine ... on a simulator. when I access myKey run the plugin from the device, I get the null object back.

not that the userDefaults object itself is non-zero.

any help?

EDIT problem does not seem to appear if I ask for a lot of full access to the plugin. but why do I need full access to use this feature? and why do I need it on the device, and not on the simulator?

+5
source share

Source: https://habr.com/ru/post/1200663/


All Articles