The App is Sandboxed for future distribution on the app store.
I followed instructions here : https://developer.apple.com/library/archive/documentation/General/Conceptual/ExtensibilityPG/ExtensionScenarios.html#//apple_ref/doc/uid/TP40014214-CH21-SW1
Both targets are part of the same app group, as it can be seen in the Entitlements:
Code Block xml <key>com.apple.security.app-sandbox</key> <true/> <key>com.apple.security.application-groups</key> <array> <string>$(TeamIdentifierPrefix)com.stormacq.mac.MyApp</string> </array> <key>com.apple.security.files.user-selected.read-only</key> <true/>
2. I am accessing the UserDefaults by the suiteName :
Code Block swift let defaults = UserDefaults.init(suiteName: "TEAM_ID.com.stormacq.mac.MyApp") //where TEAM_ID is the actual team id used to sign the app (something like 123AB45CDE)
However, when trying to read or write the defaults at App startup time, I receive this error message :
I found weird that the error message says Container: (null),.[User Defaults] Couldn't read values in
CFPrefsPlistSource<0x600002c4d200> (Domain:
TEAM_ID.com.stormacq.mac.MyApp, User: kCFPreferencesAnyUser, ByHost:
Yes, Container: (null), Contents Need Refresh: Yes): Using
kCFPreferencesAnyUser with a container is only allowed for System
Containers, detaching from cfprefsd
The group container and the shared Preference file is created (and contains the correct default values set by my code) :
Code Block ➜ ~ ls -al ~/Library/Group\ Containers/TEAM_ID.com.stormacq.mac.MyApp/Library/Preferences/ total 8 drwx------ 3 stormacq 1896053708 96 Sep 6 19:58 . drwx------ 5 stormacq 1896053708 160 Sep 6 19:58 .. -rw-------@ 1 stormacq 1896053708 103 Sep 6 19:58 TEAM_ID.com.stormacq.mac.MyApp.plist # I edited TEAM_ID to post this message
I am using Xcode 11.7 (Swift 5) and macOS 10.15.6. What did I miss ?
So that means things are working, right? So you’re only concern is the weird log message?The group container and the shared Preference file is created (and
contains the correct default values set by my code) :
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"