Adding group between watchOS 11.1 and iOS 18.1 results in Error on data save

I am developing an iOS and watchOS app that share data using App Groups. The App Group identifier is group.(myteamid).dev.christopherallen.vtipz. The iOS app saves a QR code URL to the shared App Group container, and the watchOS app reads this URL to display the QR code image. Steps to Reproduce: 1. Configure both the iOS and watchOS targets to use the App Group group.(myteamid).dev.christopherallen.vtipz in the "Signing & Capabilities" tab in Xcode. 2. Save the QR code URL to the shared App Group container in the iOS app using UserDefaults. 3. Attempt to read the QR code URL from the shared App Group container in the watchOS app using UserDefaults. Code Snippets: iOS App Code to Save URL:

private func saveQrCodeUrlToAppGroup(url: URL) { if let sharedDefaults = UserDefaults(suiteName: "group.(myteamid).dev.christopherallen.vtipz") { sharedDefaults.set(url.absoluteString, forKey: "qrCodeUrl") } }

watchOS App Code to Read URL:

private func loadQrCodeImage() { if let sharedDefaults = UserDefaults(suiteName: "group.(myteamid).dev.christopherallen.vtipz"), let urlString = sharedDefaults.string(forKey: "qrCodeUrl"), let url = URL(string: urlString) { fetchAndSaveImage(from: url) } else { showError = true } }

Error Encountered: When attempting to read the QR code URL from the shared App Group container in the watchOS app, the following error is logged:

Couldn't read values in CFPrefsPlistSource<0x300b19880> (Domain: group.(myteamid).dev.christopherallen.vtipz, User: kCFPreferencesAnyUser, ByHost: Yes, Container: (null), Contents Need Refresh: Yes): Using kCFPreferencesAnyUser with a container is only allowed for System Containers, detaching from cfprefsd Troubleshooting Steps Taken: 1. Confirmed that the App Group identifier is correctly set up in the Apple Developer portal. 2. Ensured that both the iOS and watchOS targets have the same App Group enabled in the "Signing & Capabilities" tab in Xcode. 3. Verified that the App Group identifier used in the code matches exactly with the one configured in Xcode. Request for Assistance:

I am seeking assistance to understand why this error occurs and how to resolve it.

•	Are there any additional steps required to properly access the shared App Group container?

•	Any insights or suggestions to resolve this issue would be greatly appreciated.
Answered by DTS Engineer in 806778022

Lemme confirm my understanding of your overall goal:

  • You have an iOS app.

  • With a dependent watchOS app [1].

  • You’ve added an app group to each one.

  • You save a setting targeting in that app group with UserDefaults on the iOS app.

  • You want to read the setting using UserDefaults on the watchOS app.

Is that right?

If so, that won’t work. Your apps are running on different devices and there’s no automatic syncing of app group containers between devices. So, your plan would work if you had two iOS apps on the same device, or two watchOS apps on the same device, but it won’t work with an iOS app and a watchOS app on different devices.

There are various ways you can share state between your iOS app and its associated watchOS app, including the iCloud key-value store, synchronisable items in the iCloud Keychain, and Watch Connectivity. The best option depends on your specific requirements

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

[1] I’m using the terms from TN3157 Updating your watchOS project for SwiftUI and WidgetKit.

Accepted Answer

Lemme confirm my understanding of your overall goal:

  • You have an iOS app.

  • With a dependent watchOS app [1].

  • You’ve added an app group to each one.

  • You save a setting targeting in that app group with UserDefaults on the iOS app.

  • You want to read the setting using UserDefaults on the watchOS app.

Is that right?

If so, that won’t work. Your apps are running on different devices and there’s no automatic syncing of app group containers between devices. So, your plan would work if you had two iOS apps on the same device, or two watchOS apps on the same device, but it won’t work with an iOS app and a watchOS app on different devices.

There are various ways you can share state between your iOS app and its associated watchOS app, including the iCloud key-value store, synchronisable items in the iCloud Keychain, and Watch Connectivity. The best option depends on your specific requirements

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

[1] I’m using the terms from TN3157 Updating your watchOS project for SwiftUI and WidgetKit.

Adding group between watchOS 11.1 and iOS 18.1 results in Error on data save
 
 
Q