CloudKit Sharing Not Working with Other Apple IDs (SwiftData + SwiftUI)

Hi everyone,

I’m currently developing a SwiftUI app that uses SwiftData with CloudKit sharing enabled. The app works fine on my own Apple ID, and local syncing with iCloud is functioning correctly — but sharing with other Apple IDs consistently fails.

Setup:

  • SwiftUI + SwiftData using a ModelContainer with .shared configuration
  • Sharing UI is handled via UICloudSharingController
  • iCloud container: iCloud.com.de.SkerskiDev.FoodGuard
  • Proper entitlements enabled (com.apple.developer.icloud-services, CloudKit, com.apple.developer.coredata.cloudkit.containers, etc.)
  • Automatic provisioning profiles created by Xcode

Error:<CKError 0x1143a2be0: "Bad Container" (5/1014); "Couldn't get container configuration from the server for container iCloud.com.de.SkerskiDev.FoodGuard">

What I’ve tried:

  • Verified the iCloud container is correctly created and enabled in the Apple Developer portal
  • Checked bundle identifier and container settings
  • Rebuilt and reinstalled the app
  • Ensured correct iCloud entitlements and signing capabilities

Questions:

  • Why does CloudKit reject the container for sharing while local syncing works fine?
  • Are there known issues with SwiftData .shared containers and multi-user sharing?
  • Are additional steps required (App Store Connect, privacy settings) to allow sharing with other Apple IDs?

Any advice, experience, or example projects would be greatly appreciated. 🙏

Thanks!
Sebastian

Answered by SeKiDev in 851051022

Thanks a lot, Ziqiao, for your quick response. You’re absolutely right – I now realize that .shared CloudKit containers are not yet supported with SwiftData.

In my implementation, I attempted to use a SwiftData model with a ModelContainer(for:sharing:) configuration and used UICloudSharingController to manage sharing between Apple IDs.

The ModelContainer was configured like this:

@main struct FoodGuardApp: App { var body: some Scene { WindowGroup { ContentView() } .modelContainer(for: FoodItem.self, configurations: [ ModelConfiguration("Default", cloudKitDatabase: .shared) ]) } }

The sharing worked locally (between users in the same Apple ID), but failed when another Apple ID accepted the share, producing this error:

CKError: "Bad Container" (5/1014) "Couldn't get container configuration from the server for container iCloud.com.de.seki.FoodGuard"

Based on your reply and DTS confirmation, I now plan to migrate my project to Core Data + CloudKit, using NSPersistentCloudKitContainer and UICloudSharingController.

Thanks again – your comment helped clarify things! Best regards, Sebastian

As of today, SwiftData + CloudKit integration doesn't support CloudKit sharing, as you can see that ModelConfiguration.CloudKitDatabase only has private(_:).

I am wondering what "SwiftData with CloudKit sharing" means in your context. If you don't mind to share more details about your implementation, together with the code snippet that triggers the CloudKit error, I'd probably have more to comment.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

Accepted Answer

Thanks a lot, Ziqiao, for your quick response. You’re absolutely right – I now realize that .shared CloudKit containers are not yet supported with SwiftData.

In my implementation, I attempted to use a SwiftData model with a ModelContainer(for:sharing:) configuration and used UICloudSharingController to manage sharing between Apple IDs.

The ModelContainer was configured like this:

@main struct FoodGuardApp: App { var body: some Scene { WindowGroup { ContentView() } .modelContainer(for: FoodItem.self, configurations: [ ModelConfiguration("Default", cloudKitDatabase: .shared) ]) } }

The sharing worked locally (between users in the same Apple ID), but failed when another Apple ID accepted the share, producing this error:

CKError: "Bad Container" (5/1014) "Couldn't get container configuration from the server for container iCloud.com.de.seki.FoodGuard"

Based on your reply and DTS confirmation, I now plan to migrate my project to Core Data + CloudKit, using NSPersistentCloudKitContainer and UICloudSharingController.

Thanks again – your comment helped clarify things! Best regards, Sebastian

Thanks for your clarification. For my curiosity:

@main struct FoodGuardApp: App { var body: some Scene { WindowGroup { ContentView() } .modelContainer(for: FoodItem.self, configurations: [ ModelConfiguration("Default", cloudKitDatabase: .shared) ]) } }

The above code doesn't build (because .shared isn't supported), does it?

The sharing worked locally (between users in the same Apple ID)...

If the code doesn't build, I am super curious how the sharing "worked locally" ...

I am guessing that you probably added .shared with your own code by extending ModelConfiguration.CloudKitDatabase, and that SwiftData falled back to .private because it didn't know .shared. That will explain why the synchronization of the private database works, but is definitely not the way to support CloudKit sharing.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

Hi Ziqiao,

Thanks for your detailed reply – and you’re absolutely right. You’re correct that the .shared option in ModelConfiguration(cloudKitDatabase:) isn’t supported and doesn’t compile. I had initially hoped it might be possible based on how .automatic behaved for syncing within the same Apple ID, but now I understand the limitation more clearly.

So to clarify: • The sharing that “worked” was actually just syncing across devices with the same Apple ID using the private CloudKit DB. • When testing across multiple Apple IDs, it failed with the well-known “Bad Container” and CKShare-related errors. • After discussing with DTS, I’ve started converting the app to Core Data + CloudKit + Sharing, using UICloudSharingController and manual CKShare handling.

The full transition is still in progress, but I’m hopeful that this approach will finally allow working sharing between different iCloud accounts.

Thanks again for your support — it really helps to get direct feedback on what’s supported and what’s not.

Best regards, Sebastian

CloudKit Sharing Not Working with Other Apple IDs (SwiftData &#43; SwiftUI)
 
 
Q