macOS Sequoia: Shared UserDefaults don't work (the app-group is set as per macOS 15 Sequoia requirements)

I use shared UserDefaults in my Swift FileProvider extension app suite. I share data between the containing app and the extension via User Defaults initialized with init(suiteName:).

Everything was working fine before macOS 15 (Sequoia).

I know that Sequoia changed the way the app group should be configured. My app group is know set to "$(TeamIdentifierPrefix)com.my-company.my-app".

But the containing (UI) app and the Extension read and write from and to different plist locations although the same app-group is specified for both targets in XCode.

The containing app reads and writes to "~/Library/Preferences/$(TeamIdentifierPrefix)com.my-company.my-app.plist"

The Extension reads and writes to "~/Library/Containers/com.my-company.my-app.provider/Data/Library/Preferences$(TeamIdentifierPrefix)com.my-company.my-app.plist"

Both of these locations seem completely illogical for shared UserDefaults.

I checked the value returned by FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: "$(TeamIdentifierPrefix)com.my-company.my-app" in both the containing app and the Extension and the value in both of them is the same but has nothing to do with the actual paths where the data is stored as provided above. (The value is as expected - "~/Library/Group Containers/$(TeamIdentifierPrefix)com.my-company.my-app/"

P.S. Of course, $(TeamIdentifierPrefix), my-company and my-app here are placeholders for my actual values.

A shared UserDefaults, or a UserDefaults created with init(suiteName:), works correctly on my side. I tested with my app + file provider extension in the following way:

a. My main app writes a value to the share UserDefaults:

let sharedUserDefaults = UserDefaults(suiteName: gSharedAppGroupContainer)
sharedUserDefaults?.setValue("09876", forKey: "TestSharedUserDefaults")

b. My file provider extension reads the value:

let sharedUserDefaults = UserDefaults(suiteName: gSharedAppGroupContainer)
if let value = sharedUserDefaults?.string(forKey: "TestSharedUserDefaults") {
    print("TestSharedUserDefaults = \(value)") // print: TestSharedUserDefaults = 09876
}

c. gSharedAppGroupContainer is defined in the following way, and is shared by the app and extension. Note there is a dot (".") after my team ID:

let gSharedAppGroupContainer = "<TeamIdentifier>.ziqiao.test"

d. The App Group container is entitled in the .entitlements file of both the app and extension. Note there is no dot (".") after ``$(TeamIdentifierPrefix)`:

<key>com.apple.security.application-groups</key>
<array>
    <string>$(TeamIdentifierPrefix)ziqiao.test</string>
</array>

I verified with Xcode 16.2 (16C5032a) + macOS 15.3.1 (24D70).

If you do pretty much the same thing and the result is different, please consider providing a minimal project with detailed steps to reproduce the issue, I'd take another look.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

macOS Sequoia: Shared UserDefaults don't work (the app-group is set as per macOS 15 Sequoia requirements)
 
 
Q