[SWIFT] [App groups] What to check when UserDefaults data is inaccessible

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.

Set Code Signing Entitlement

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.

image.png

Recommended Posts

[App groups] What to check when UserDefaults data is inaccessible
[Swift] Use UserDefaults to save data in the app
ParseException: What to do when Unparseable date is reached
[Android] How to check if the Google Play developer service is installed when the app is launched
What to check when rails db: migration does not pass
Introduction to Ratpack (1) --What is Ratpack?
What to do if the app is not created with the latest Rails version installed when rails new
[Rails] What to do if data is not registered in DB
What to do when javax.batch.operations.JobStartException occurs
[IOS] What to do when the image is filled with one color
What to do when "npm ERR! Code ENOSELF" is displayed after npm install
Notes on what to do when EC2 is set up with t2.micro
What to do if tomcat process remains when tomcat is stopped in eclipse
What is the right migration data type? ??
LIMIT 11 when data is acquired by irb
What to do when a javax.el.PropertyNotWritableException occurs
What is the data structure of ActionText?
What is Docker? I tried to summarize
What to do when undefined method ʻuser_signed_in?'
What to do when you want to delete a migration file that is "NO FILE"
[Swift] What to do if the app icon is set but not reflected
What to do when is invalid because it does not start with a'-'