Failed to read values in CFPrefsPlistSource iOS 10

旧街凉风 提交于 2019-11-27 03:06:16

This is actually a spurious warning that was introduced in iOS 10 and macOS 10.12. (Source: https://twitter.com/Catfish_Man/status/784460565972332544)

The advice of prepending your team ID will silence the warning, but will also create a new empty user defaults. This will result in any previously stored data being unreadable.

For the time being, the solution is just to ignore it.

Also, Apple staff member CFM on the forums:

The logged message is spurious unless you're doing very specific things that I don't think are possible without using private functions (it was added to catch misuse of those functions, but unfortunately also caught a normal usage case).

Here’s how to use NSUserDefaults with App Groups to pass data between your main app and your extension:

  1. In your main app, select your project in the Project Navigator.

  2. Select your main app target and choose the Capabilities tab.

  3. Toggle the App Groups switch to ON. This will communicate with the Developer Portal in order to generate a set of entitlements.

  4. Create a new container. According to Apple, your container ID must start with "group", so a name such as "group.io.intrepid.myapp" is perfect.

  5. Select your extension target and repeat the process of enabling App Groups. Do not create a new App Group, simply select the group that was just created in the main app target.

  6. When reading or writing NSUserDefaults in either your app or your extension, do not access NSUserDefaults.standardUserDefaults(). Instead use NSUserDefaults(suiteName: "group.io.intrepid.myapp"). Note: The suite name is the name of your App Group container created in Step 4.

Make sure, group enable and using same group id for both extension and app capability section!

Credit goes to http://blog.intrepid.io/ios-app-extensions

I’m facing this same issue when I’m trying to use initWithSuiteName. Seems that this is a bug from Apple. The only solution / workaround I found is to reset all the settings of the device. Go to Settings -> General -> Reset -> Reset All Settings.

This doesn’t erase any content on the iPhone, just erases all the settings. After resetting the setting, everything worked fine. Let me know if it helps you too.

Also had same issue with my macOS app.

Solved it by: Reboot the device!

https://stackoverflow.com/a/39876271

The SuiteName (postfix) must not be the main Bundle ID.

Build with Xcode 8.1 Beta and you will see the same warning, but you will also get the value.

H u Y an g

if you suffer this problem when you try to save data to extension APP by using userDefault, maybe you had written this code:

[[NSUserDefaults standardUserDefaults] initWithSuiteName:@"group.xxx.com"];

This code reset default userDefault.

Actually,the correct code is:

[[NSUserDefaults alloc] initWithSuiteName:@"group.xxx.com"];

http://www.jianshu.com/p/e782104c3bc3

Titan

Change from

[[NSUserDefaults alloc] initWithSuiteName:@"group.com.xxx.xxx"];

to

[[NSUserDefaults alloc] initWithSuiteName:@"nnnnnnnnnn.group.com.xxx.xxx"]; 

Where nnnnnnnnn is your team number, the one which you use to sign your code.

Tested under Xcode 8 GM and iOS 10 GM, and worked!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!