{"id":32033,"date":"2021-03-31T10:08:34","date_gmt":"2021-03-31T14:08:34","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=32033"},"modified":"2021-03-31T10:16:30","modified_gmt":"2021-03-31T14:16:30","slug":"how-to-set-up-core-data-and-cloudkit","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2021\/03\/31\/how-to-set-up-core-data-and-cloudkit\/","title":{"rendered":"How to Set Up Core Data and CloudKit"},"content":{"rendered":"<p><a href=\"https:\/\/beckyhansmeyer.com\/2021\/03\/30\/how-to-set-up-core-data-cloudkit-and-swiftui-when-you-havent-the-faintest-clue-what-youre-doing\/\">Becky Hansmeyer<\/a> (<a href=\"https:\/\/twitter.com\/bhansmeyer\/status\/1377261355842031621\">tweet<\/a>):<\/p>\n<blockquote cite=\"https:\/\/beckyhansmeyer.com\/2021\/03\/30\/how-to-set-up-core-data-cloudkit-and-swiftui-when-you-havent-the-faintest-clue-what-youre-doing\/\"><p>Turns out, if you want to sync Core Data-backed data between devices and have those changes reflected in your UI in a timely manner, you have some more work to do. To figure out what that work is, you can&rsquo;t look at Apple&rsquo;s Core Data templates. You have to look at their <a href=\"https:\/\/developer.apple.com\/documentation\/coredata\/synchronizing_a_local_store_to_the_cloud\">sample code<\/a>.<\/p><p>[&#8230;]<\/p><p>Don&rsquo;t be like me: make sure your schema is deployed.<\/p><p>After launch, remember that you still have to do this <em>every<\/em> time you change your Core Data model, before you release your update to testers or the App Store. If your production CloudKit schema doesn&rsquo;t properly correspond to your production Core Data model, syncing is going to break in all kinds of terrifying ways.<\/p><\/blockquote>\n\n<p>Previously:<\/p>\n<ul>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2019\/06\/04\/syncing-core-data-with-cloudkit-and-nspersistentcloudkitcontainer\/\">Syncing Core Data With CloudKit and NSPersistentCloudKitContainer<\/a><\/li>\n<\/ul>","protected":false},"excerpt":{"rendered":"<p>Becky Hansmeyer (tweet): Turns out, if you want to sync Core Data-backed data between devices and have those changes reflected in your UI in a timely manner, you have some more work to do. To figure out what that work is, you can&rsquo;t look at Apple&rsquo;s Core Data templates. You have to look at their [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"2021-03-31T14:08:37Z","apple_news_api_id":"3b7b3835-d8f4-46ec-8ef9-12919fad7dd6","apple_news_api_modified_at":"2021-03-31T14:16:34Z","apple_news_api_revision":"AAAAAAAAAAAAAAAAAAAAAA==","apple_news_api_share_url":"https:\/\/apple.news\/AO3s4Ndj0RuyO-RKRn6191g","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[916,109,16,31,1837,30,1891,71,1774,269],"class_list":["post-32033","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-cloudkit","tag-coredata","tag-icloud","tag-ios","tag-ios-14","tag-mac","tag-macos-11-0","tag-programming","tag-swift-codable","tag-syncing"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/32033","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=32033"}],"version-history":[{"count":2,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/32033\/revisions"}],"predecessor-version":[{"id":32040,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/32033\/revisions\/32040"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=32033"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=32033"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=32033"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}