Data cannot be accessed when using UserDefaults with App groups. In my case, the problem was that I didn't have the Code Signing Entitlement setting in the Signing settings in the Build Settings. Normally, if you enable app groups and specify a group, it will be created automatically? I think In my environment (Xcode 12.0.1), it wasn't set automatically, so I was able to confirm and resolve this issue with reference to other normally working Targets. By the memo.
First, create the XXXXXX.entitlements file. XXXXXX.entitlements (XXXXXX is an arbitrary file name) Create a file. The content is the following plist data, and the ** group.my.appgroup.id ** part describes the app group name to be used.
<?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.my.appgroup.id</string>
</array>
</dict>
</plist>
Add the created entitlements file to your project.
Next, make the settings.
Select TARGET which is the problem that app group cannot be used, Set the file name in Code Signing Entitlement of Signing in Build Settings.
Recommended Posts