---
title: "Discussion on \"How to migrate NSPersistentCloudKitContainer to App Groups\" | Hashnode"
description: "Discussion on \"How to migrate NSPersistentCloudKitContainer to App Groups\". iOSdev / Core Data / CloudKit"
url: "https://hashnode.com/posts/how-to-migrate-nspersistentcloudkitcontainer-to-app-groups/647a051fed1f885a817b70ce"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [How to migrate NSPersistentCloudKitContainer to App Groups](https://blog.next-planet.com/how-to-migrate-nspersistentcloudkitcontainer-to-app-groups?utm_source=hashnode&utm_medium=feed)

iOSdev / Core Data / CloudKit

Jun 2, 2023 · 13 min read · blog.next-planet.com  
Updated Jun 26, 2025  
Read the article

-   [#ios](https://hashnode.com/tag/ios)
-   [#coredata](https://hashnode.com/tag/coredata)
-   [#cloudkit](https://hashnode.com/tag/cloudkit)
-   [#backend](https://hashnode.com/tag/backend)
-   [#app-development](https://hashnode.com/tag/app-development)

## Written by

[Kris Slazinski](https://hashnode.com/@kslazinski)

@kslazinski · Poland

  
[View profile](https://hashnode.com/@kslazinski)

👨🏻‍💻 UX Designer, self-employed at NEXT PLANET - small design studio. 👨🏻‍💻 Indie iOS developer 📱 Creator of: Moons, Numi, Skoro, Wins and Emo. 🎸Guitarist at ZERO and Quadroom 🎨 MA in art 🌱 Vegan

## Responses 3

Markdown supported · ⌘↵ to post

[Ivan Amakhin](https://hashnode.com/@hoxel)

[Dec 3, 2025](https://hashnode.com/posts/how-to-migrate-nspersistentcloudkitcontainer-to-app-groups/647a051fed1f885a817b70ce/comment/692fca08e3747d7abd0bc704)

You should reset context before destroy container to don't get crash.

Cannot attach stack overflow link but you can find core data error

"Core data crash when resetting the store: 'Object's persistent store is not reachable from this NSManagedObjectContext's coordinator'"

[Rodrigo Castillo](https://hashnode.com/@rocasa)

[Sep 18, 2024](https://hashnode.com/posts/how-to-migrate-nspersistentcloudkitcontainer-to-app-groups/647a051fed1f885a817b70ce/comment/66eb4b36c7a6d2155fb1ab16)

Thank you very much for this code, I tried with ChatGPT and a YouTube video to create App Groups but only with you I could do the migration. The only problem, which is still small, is that the following line gave me an error because the database was not found:

init(inMemory: Bool = false) { container = NSPersistentCloudKitContainer(name: "iCloud.com.yourDomain.YourAppName’")

It should be only with the model name, ie: NSPersistentCloudKitContainer(name: "YourAppName’")

Rodrigo

[Kris Slazinski](https://hashnode.com/@kslazinski)

[Sep 19, 2024](https://hashnode.com/posts/how-to-migrate-nspersistentcloudkitcontainer-to-app-groups/647a051fed1f885a817b70ce/comment/66eb4b36c7a6d2155fb1ab16#reply-66eba1c40458b2734f7013f4)

Hi, Rodrigo. Thank you very much for your comment. I am glad to know that my article helped you 😊 As for the NSPersistentCloudKitContainer name... Did you maybe call your container using the "YourAppName" pattern? If so, yes, you need to use the same name in code. I have the following note in my article that explains more about the name of the container. Please let me know if it's still not clear and needs changes.

"We set our container as an NSPersistentCloudKitContainer with a name similar to "iCloud.com.yourDomain.YourAppName". One note here: while Apple suggests this naming convention, you can as well use a different one, for example, "iCloud.YourAppName". The most important thing is that this name must match the name of the iCloud container selected in the Signing & Capabilities tab of your app's target."

[Christopher Tibbs](https://hashnode.com/@eggyeggbean)

[Dec 20, 2023](https://hashnode.com/posts/how-to-migrate-nspersistentcloudkitcontainer-to-app-groups/647a051fed1f885a817b70ce/comment/6583044213bee953f6478462)

Thanks a lot for taking the time to share this knowledge, Kris.

[Kris Slazinski](https://hashnode.com/@kslazinski)

[Dec 20, 2023](https://hashnode.com/posts/how-to-migrate-nspersistentcloudkitcontainer-to-app-groups/647a051fed1f885a817b70ce/comment/6583044213bee953f6478462#reply-658308c4dce0028533ef1e48)

You’re welcome ☺️ I am happy that you found it useful.
