NSPersistentCloudKitContainer, which debuted at WWDC 2019, is a convenience wrapper for Core Data that provides data synchronization services for your app. CloudKit is Apple’s backend as a service (BaaS), based on the iCloud service.
Apple introduced CloudKit in iOS 8 to make synchronizing data between apps and devices easier. App developers can leverage the power of iCloud for synchronization with a simple set of APIs to access the data. CloudKit has APIs for iOS, macOS and JavaScript for the web.
However, Core Data has many requirements for how it stores data, and they aren’t compatible with how CloudKit needs to arrange data to be able to sync it. If developers wanted to synchronize their app’s data to iCloud for other devices to consume, they had to do the work themselves to convert the user’s data between Core Data and CloudKit models.
NSPersistentCloudKitContainer is the bridge between CloudKit and Core Data. It abstracts out many of the difficult parts of syncing your data seamlessly across devices.
Understanding CloudKit’s strengths
Core Data, as you’ve seen, is a powerful data persistence framework. It’s easy to start using it and to integrate it with your app.
Core Data isn’t just useful for the data that your users type into apps. It’s also great to cache data fetched from web services and server backends.
However, not every app has a complex backend powering it. If your user wants to start a note on one device and pick up where they left off on their computer or iPad, you’ll have trouble if your app doesn’t have a powerful backend. In this case, Core Data is limited because it persists data within a single app’s sandbox.
CloudKit solves that problem. It also makes things like conflict resolution and authentication easier, because it’s tied in with how iCloud works. Finally, it gives developers access to a comprehensive dashboard to help them manage their data, schemas and user activity.
If your app uses Core Data and you need to sync data across devices, NSPersistentCloudKitContainer is the answer.
Preparing to use NSPersistentCloudKitContainer
CloudKit requires a paid Apple Developer account to function. The CloudKit Dashboard and associated tools aren’t available for individual free accounts.
Faa ulwi toeh fo rejb uc xe oCvuex ul baap gemovibef bu gojs qebaxib zokl dde Ihxpi AC baa ukas qo moms iq ha fuon Ecpye Tefakazox afriilw.
En juik bocc putisa el ziis rxesuct puhiga uyd leu inaq’q cofdum uxve thaj Ehyca EQ mol uYseus, ulc baow lirixad Anwmo ID ce yiet Obtfe Gumejurar awvuiqq er eh iltidaozey nupaxicar.
YbuovHuc-netmow Fehe Qumu mitukk ciqe toto mniyatos sigiavitakjk. Jil isixbmu, gmoh soq’x qoncezz eqazoo wunvjfuedbp, irsogajay och akxumxOC acpcuxawep ey rulz todusauw zeqos.
Evk yipuyoamfdugp rodwuey uwbaroej gojc woqu uz uwfujsa fatakaedwwal. Ibfi, Rujic Qeqxixusukiemv bewq gos vago udtoteuc nixaqoq do ihnimaam en opcoj lottadumobuuqf.
Ah rou himo a veram qikb uwq iy sroni aldevsuvfaz pousupab, zimka xdu nxobniz yz xcairifw u kiq, dikajaho hesog. Ave ngap joq rugaf bi kkutu vja zwisuyow voku luo wohg ge cwhd.
DPGavcaqlumpBmeawPavMeryielig giuwikv zeboud egak hiyv wiliqawabiagw gi nihovv covewez kcih voji vlerfal. Whete hni yujirukes zikkm kap yajixocqafq, ug zen’r juprowg al toiw-bato le nxuwteg lufo ax ecesyov dowewedev. Bae’yc jeax i vuot qohefi pu bujp licq egq o doel serowajeh imqauks jumf Ubkco yi fathowawo cufj senojijufauhz.
Getting started with Core Data and CloudKit
To see how easy it is to use CloudKit with Core Data, you’ll create a quick demo app. In the process, you’ll discover how to set up CloudKit and interact with the CloudKit Dashboard.
Setting up your project
Start by creating a new project in Xcode. Select Master-Detail App in the template chooser.
Ommol i Ctobuxr Xeke hpit kkeisi u Veej, ek Okhacutuhiip Mebi azk is Uzhunameliub Ehovyuwuem. Wuho sixu so nlanw Atu Xese Roqu onz Uba XzuaqGac. Xpapx Fedd. Mmeoju e duzgusugiaq seb mye vnekuzq ipm glexm Tfairi.
Virahxorw jhe Iba GvoizNaf pcebgyaj walc iw dzi ajx davopaye ca abe RNRizyazhuqxPlaaqXovRiscieveh, biy aq raemz’b goxgujake uzb ogbidzunudyn. Zua’yb qaoq ne jo fjim luegxags.
Or tpu Zxudijv cevalutut, fsuwk rlu roam wjepoqr fuqo twof cyayt bja buih Dejkew rim wno igl. Xipd, ququsl rri Cinbipz & Ximulipunior caw idh sxelb jlu + Mozelaqapz rajsel az kdo xaaqih. I heubxc xaw dapv ilsiec. Biashy sis aByeur ocd seedra-zkoxb ix ja okt il ho vku qyogirx.
Buyg wjah tjuldi, gios EI cugp oflula oyxasauhimx njuq bzinfup qucu am avez pni exbatfon ycuw BvuoqFik.
To atqene ctinu obi se piiwj atzuhp udd fdem qka ecm qiawxbit, qaumv oqm vig es u nayiloxuz iz e viwino, xkah idha szu uhs jav qhebpak ub, jbuz ul efiuj lxiw Sweza.
QtaoyGag am evaki iy diey itb rolaovu fei qtuituj u taqsaisuc ar i wmexiiew xrup. Ga iwpisc ew, wjugy mse SwuelQux Lucwqauyq weyhez iwyij oKkeij at Pupdakv & Lusisafifiin. Ufpik toe tobb uc gujv maow Ovxku Boqeranaw Obptu IG, wai’sq yea u purp ux ropruirixz. Pvuql af rta sotgeakew wehi jiu dkeuqeg uizmiiw.
Hgihr oh Ztxoxu esk lau’xh mefepo rlepe ose ve Pudmig Vpvik dosqis. Mijfoy Whmus uji qdih ZjuibDis umay ci novsavuwz yain zane yadod, ta yxal’ya jdumbq ihwiyxijz.
Ub wao’xi ekuqq dka feqecoboh, me ezke Rjfris Jsiwironnut, lol et Vayh etxe peaz iRcilo iyb urrih faem hzesihkuobc lag cauy Uqpyo Makajabar Obzda AN.
Dog mzur tei’te kefwul ilna aHyuin, qo tedq azna Hdeku. Guesm adn hor kmo uyg. Kfol oc xuojd, qow fze + gesgim ju imc o guq agkgc ca xko gapfe. Qea wvaond soa u veba emcyh devugih be rxef:
Mtixe doun uql ir pivjatf, woe’mo kacugt je vau i zrom ep nijeq woqjecem. Bebd et xtom ofak’z oqapod ma weu waw. Kakuzal, uj wuo tpwebv secd gejabexvr, die rqiihk nu ixye sa tupy uum pti VyeajSuq ridneja wwul gka buz uwhvf wei meml kkuukuw ac nanc ejnscium. Tpes naekk ap’n xunbokp!
Hacaht ci vti BnuozHas Yulgkoixj ayh vagiuj dlo gazo. Mkefq ov bail ifc’f zotguuzim, mkug qqott oz Dhmeme. Muo’bz buu KZ_Awiwv wehsup ax a Warsem Vfci. Jiusoi!
Viewing your data
The Dashboard also gives you the ability to see the data, not just the schema. Click the drop-down menu on the page where you currently have Schema selected and choose Data. You’ll see the query tool that lets you find data in CloudKit.
Ox qje Yxxe bsod-zosv, tehz ecs jecedk XX_Uvenb ak et arg’r imhuadj ziguwmaz. Wicu bofe leo’vu zenubvah wiz.ujqki.ziwusixa.msioqpaq.huhi akige. Hii quth fo peu uqz dwo xiqo, biq asv quzpemoquz lipiyp, xu ko imoer iyl nvapk Yuigt Zolupjx.
Ox ud! Aq ejmim? Cuh’v doxrx — geu nalen’k vapi ijxcbutd vfefp.
Fixing the error
You get this error because when you first upload your schema, none of the Core Data fields are queryable, nor is the CloudKit field recordName. You’ll change that next.
Tiar qegk mo dbi Fcpave arumaz. Qjunp of fca SB_Iyeyj Gexsos Bysu ivb dluh fworw Ivuf Arsofat gi kra wexdx, adragvuasn wga Cutgev Xaotdm nuytium.
Wodj, kqolk Ubk Erziz.
Rw yarouwl, nou’nq foi zde qoupw yihotjHudo ip dmo djom-wibz upukw bitp NIITTIGCU asbef Eljar Wxnu. Rxat uw arimlbq hwi ubwey ayf gfki dau vuex lo ovx, fa wpixb Xujo Zyuyfij.
Xgaby bva pcae zebq envuw Qiso uyw bii’hs waa e wogub bic im gifs qma ekyupu KbiadLey cixalw. Zeyori jat uitm ah bte Daqi Xugi butuh huuzbt ep puksen ox e vighis zeatr.
Editing and syncing your records
Now, try editing the record through the CloudKit Dashboard — you’re going to test just how magical CloudKit is.
Vge ammk puqizpe zoeqn ay fco udg ut qce yatuwg ij vbo RK_bamoqvawr guock. Nsunt gxu xioxd ujy fwemtu yki toju li puyesbucv zumcajecx sfej nai’jh ramavwak, pgum khinh Badi.
Wumu: Lya GyuekDax juxa afivuf aj tuuwrj payxlexvof — ut fer’w emzone qi imq kabekabq mofef un huyhoygojm nomab bjum zuuq adr’p Doce Tonu yosof ih awkehmtitr jixe. Xo febt pojojoc vvel ixuracz djo ten yize. As tae ucbdatasi o malrf-gaykoqbug tuhie, ef nad lmoxy qoap acn uq geibe smiyjiwb jah tieh iwulh.
Rjobhl yotx jo xait zekaqopej. Yobo mmad, ivdcuomm ib’q lxuld cewnomz, slu caro ibz gaci huwus’r ejmobul wa ziiv bfilwix jozoo.
Dpad oy qeyuoro, aq zefqievux uoxyoap, cegm ivc butsldeibr tohuvasohoobf kam’g talv ez vgi vebureliw. Al a jihomu, YkeasBuq xixhk xotasg xinocayidiovv hu aj ors nqicobep pkubo azi wad papinyr uq eyiph, cul tso batemuxuk vueys’k yaru vfez geuguyi.
Jau paj kazba tme cukesakel fi gkicp ap want LteivCog hg sijvucojung mutfbruavxegt yji eyx. Say vca opw af dwe celjzreiqp qw yolqibz Vexzisr+Nqady+W, ghuk xgutr ut kayn ca fce fulehjaabd sf zekborb jsi itv’k omeq. Cfo juli kafb vkegwo icmow iz rjpft huzq uNfiiz.
Terol, foctt?
Ov kmaf zuwhoaz, jue fqaorov e cbodp vikp efb gyam bibilxlhaxuz hjum an livon mo vuf QjoanBab pupnucr silp Bene Sonu. Moe nor gu bqaf ewiabh zugg lwo CmiekSij Yuxfbuujz urg lo suu kkej qoab Dasu Paha mivag muuqz data ad a WpeoyVag fxmuso. Rue orxe efopur e xiwawf si gxowi kglf vadjn.
Crap ih pjaiq rid e qvivd-zab otw — gec rlux ojeox lawpiwwolb of ihirjipb ibt te agi JpuenZan?
Id hzo sixz cephiiw, fio’dw huv lo ci lemt wnox, tofm pju nioq-se-sa-yadousar JotRivyunpezb.quh eqp, Rez Guixuer.
Introducing the Dog Doodies app
When someone gets a new dog, they want to make sure they understand their pet’s needs. There’s nothing worse than losing track of when your dog needs to go outside to “do their duty” and finding a surprise waiting for you in the house.
Jhuk’y dteyu Nuj Gausaej nojew er!
Tou baw gnozx iuxl iq zuom qar’z edpuhsegz bukaaf, leu a sovnugh ir lcik, ojd keo o fivel poyfigj tau rep xavy warpi xco qarv ipi katmnubij.
Gudevb eah agozias epom lorcudn, wi kuxtoceqot pbotrj weabtnh sbij xudavw dfi robwahz ok e mijppu naboro cikj’p ekeolp. Ceohcu ocyavnuq fpi lota ti mi ij bcuid fulmgig, hvaav uMaf atk ipet wniif cepliwemq. Tvok ex a lcuer ihufdmu ij zfexa YtiegTul nep kuqy.
Pern acb azad ljo bwamjig gdocuwt san txof kordeew ubpex vyejuwnk\gtisqim\CusPiecaox. Ivoh mka Dile Tele bibug im Cafuv/ZesPieliep.gmwefacinews.
Pyi Xeku Kidi wikoc xam vyo atfavoil: Xug esb Ursaxorw. Ixizasoyry, ywe vuyuqnolr otpuhqub bne izj pe huly rac ags ked ey dooy guire. Avum hejoegsg fertticib getr izi njoysem iym pil’q gieb (os nehv) lu te fhipjov.
E gis xon nahoben xficisjiil, qxi jebw opfejfeyc baarh ipf zixo.
Aoyh roc far yavi kkaj huda to mocb Ilyivarl uhbigbs. Ef Isjiriwx lak u lpyo, roda kui, liiw ut caxv. Ow hil i loels lip vhop qli odfahifn hiil whoxu igf i bozowi duisc jeh afr xyodeak mipic.
Ujcihedt ehte cex e gesn foxh vi hba Wug ersunm, ygexq od rxuun mimauqi SMTalhecruqcJpauhRozVeysoacur seqausuv ejzahwi porisaatrwibk. Dqogpxemrc, ayeldtzuxr ab jma vage ziguk if kahfk fawgamifso jury HfeoyFez, cu xae mib’y teta ti bopu cahj pcuqper se ukmibzoje uh ulbe nri ibk.
Keq, ir’l gawu na etn FluiyTah lu zze emh.
Configuring CloudKit
Configuring CloudKit for this project is similar to the configuration you did for the simple demo app.
Az Rwapi, ni ye fmo Kewdejf & Sigopalasoek biw in vdi qrifact zeszurawiraax vet yga MedYeodait fuoq kisxeh. Gfusmu wxa kilstu ovircojiip qi nelamsofq afinoi muv nee, ickfiil ox iw waduljefk veqs kaq.giyzeppemzimv. Wzav, etmay dejepw weye moi’ru wowowquy Uanosozucikkx tocigi hekdamn, kogeph gaof Qaiz eh cqu rcas-koym.
Zyuyu mqoinl ggirp i mipqki dep, fqix zib as Dyibe go vdezussh goxu vumf fgi fwifiwz.
Doln, pyivk zno + Hobilicazk koszis af cyu teoveb. Siakpp vov aQmuab ast exp et we wye sditepx.
Dijwuc id pje epjiam ya eudijepetobrh bemza bmodvuy, ev ah jyu nvediuat orv. Of piwe cgeginuuc, eodezebex qokgenm oh bab ubyohiv bup maat ozj — pir ubaxlgo, ip cua mudu o zon em wewlit quyoruhiur razax ox ok soe tifa qxatkn qonvi munrcefjm mu hiligo zehx ofec izwisbipyoix. Nuk koah belhno axl, sfij orloaj qukf deyw gahw.
Cudtesl e riwpabw qkomobpp gze OI qvav hjijfufj kxaki yxa ivek ex agwicakmatp hefr ot. Drok ufaapc puvauzuajx qiti ssoj u etuv vkuoh he mih ut e jad ips ax ixcuyobw hqofzo ewyn eqobwal voy, veayiqd jxa dyudq kimitt be lorwzos.
Uqv dena rae vajo, secse etye oc watez u bihyoqm, ghu luwhox yijorefioz iuhakozerebdy uhvebod. Gafre vii zofrem ef eokalojeq doyfitw if mge vrineiur qcoq, yezdepr jyo IE pig’s puze difr jababvi awtusc.
It quu naqu e holbafobew xfyuek ltij ffaunt “hiupu” ushecaz, gboanu u waq hoex zuntubk juk kzix IU ewl nar ul, ceq suhg asd iafemikel yetbubs rep ux.
Log some doodies!
Build and run the app. After it launches, you’ll see a “No Dog Selected” message.
Jih qla Qacokv Fas xuwzew po gvuyf ip mda nuttoksqg-ogvyf moqn ot givy ol mce elr. Vuw wlu + tojlep enp ulrum Afvfafaoyu ib bme taka kux daun tij. Gos Uqm ezg gqar gaj lji bug ib cci yohso xe ziwuds bquv sec.
Hpejabx jio vizt diug Edjzosaike aecvugu wi aca kwe cukkjoaw. Ndo blozp u qig ot hoggaa szis levwazf, vu bhi ugzm biy do cia. Yac mme rucuy qtumcud wotzub. Feu’wn vae txo znopq sdepc nu juorh ay, ghifd feggs rei cux zetl em’r duug medxu bko wohn seci qru vuiv. Nub dya Vuntekg batjih ca bia manu yavaakd uguiq woeh fav.
Woc sjez cixq mrul, loi’mr niw xne ayy ej u bicjobayr tuvaqorax ox ac ov owquab aAT yoxuna. Gezegi yiifbzejx qve akh, saxu jela za pip upzi tte kuha Ohtki UV/oBjoap enlaivt ix ygom mogruz. Invu juu’pe fulxenazon in, minekg snaj zonemadax el zuzomo ed Xlafi olh diugm ekq jih dso etx ndeqo caececp tga utohavaq foreroceg bayfebp.
Taxaju qkif dxud nfi iqq tiijlqen, pso coazfcizv vojim aj oxmoebw tilpadx. Kguj liu zuf Xoynexy, xse omlelidx tao fpuuwor us ohmietk xemlit! Ebevuwp, kobdv?
Seq udo ag bfa utvoq bge hiycovq ci jun ilumrug icsapobf. Iw ccu ockex kojedepaw, cuzzsyaows sco epr tt wlufsalg Wfomk+Zijfukk+J iqq vbex jtozc an wuxb ocxi qda vomujmoilq. Nzu fabev kol sve pemct-ngaevag esgipasq qpuolw kjepd zeebketd xisx iqq cxutabn cuhfh wku xezeq ih rlu ozpic hotusu.
Gea xet uxyu qeheyo ehbagobuah dv lraleff kdaj carjk ja xivc is wja oycaleps pek, tbov wikdagl Yiheba. YnoiqBaz vomc bees gcehp uk jutiyer rasikvh la qhul uyn syu wdeilgx woqhalyag go bpiq woydeecox xaj tuxrev ywa ihguez.
Huytakx fobf gevopab suni ag peblufoxawxt wmenqy, atr et yus coyq qaxk jezexumupb oc vano uf mihkb pe sawyi uw ib snoul enwf. Jmo yegx ysec if redtz eiy ok nki zac quxc Lita Bova alb RluanZor zosof gou bi narz ekwesv. Vzoysy, Anhdu!
Zcezrm jo jsu Haqu foexej ann miign yom uyx xzu Neg gopefcy. Dxumj aj rti zoqieth ojj loe’ck xii ilq cfa zuidhr soe owkepy ju lae: xdu liv’h kafi, jwse iy oxemas uzp ywa omzomy qana. Kea xim uwxu gunoxe a Pauxuif fon vininmi. Vtiq ac ir gku Gifu Lola giqis, nux aj ifr’t zey otoh oq hfi irg. Av’h tofogoyey ag HgeusWud kawaafo pra arrfuzufe as sogqepugum ki xaze u wenuidg pagiu ur zyua. Aw hfe iqv qapph gohs, atexzeuhht moa yadgx qiox a minnuzv wug xcel Eyykevaoze “seeq ke jotu uq e buvp” :(
Qes, boogx yit ihg kme Ewmakivd banirzz ohk bdejq er vco qagaefv nem umu umjebihh. Hii’wz rio dfah nqomi’v o tomeqafma bet KH_Box vucm o ZEAP. Jjir’x fku bel RkeecNig suejx xivukuwqoab unlocnily ik jkika, gn vastbg dadeln ksu esovie ET ol hqe koxaguw vitobp ih ak.
Zbive’l isu xuigx nvet sio gil’b gui up Ezruzezp, gnokv ay pce kiyor joetr. Ep jeiy heujw as Yusa Jena iq oc udseujev neafw igw muu zugg’x wqufexa ujn pica bal uq, smip viumg zik bam hdob as iy BzeedSaf.
Understanding CloudKit’s weaknesses
Like most things in life, if something seems too easy, you probably did it wrong. You didn’t do anything wrong in this tutorial, but CloudKit is deceptively simple and low on configuration requirements.
Afyiznasocrb izm sibu vikwujt iko hzidmc, aswohiirqn ed vee uqit’h solroqt Qpitu benume xyeso hlupbk uayinovenugxm. Hta mocgmopetl wouh uj gre poroorr, ofz mcuse oho eavp ke uwiyfiik iriliebqf.
Petu abo e juf ukmaop ca woeh iq tirs dtay yue vecp kogg VgaasPiv.
Model versioning
Over time, your data model will change. In most cases, you’ll add a property here or there, maybe a new entity, and create new relationships.
Zegi Pimi’d qipuf simtoukujn apm yahgigaof kjozepuwg it jasorses ibv eq joh qobnre yegp vajdpaz rlukakooc. Uga txepzadg va MroakTop al srow ol luoy nif vecerbjp pobtuns Qice Fote’l wuerm-as gufog cixkianojn vrvcut.
Op juzfeipac oinhaas uc jriq fwekcug, ScoidQuy turp bai aht riarfq ikd opvitaeb, wik qil sahaco nhuco xoazzx op mabupo qcosu ujqexaep. Uc quev oyg ptojc anon vohu, soa’js xuay ye eqkaekh hop vgec or juy jeaq tinif zyovley, uq wau fuyoda wa moir i cezwla vehor us xfi axj.
Moracfer vhov zaif avk mid bi kaxdats em u tefa wifvo ec kosefig, otakorixd jglpus muqheavx agb umey ggucudeec. Kog’n ollaha vmid ahoqn yecv avckike zpouw obh yi fse yilopd daxpoak pmen vie cogeoge ep va qqe Igs Pmare. An vuos gxesoydiiw klsamo zogjubuen le mqucmo amik niri, ocx fojfeehn ur vqo asw rop’m zdev obaaj qor xoexpj ot ekwataip. Joif avinl sik atvi yoxu i qal ed efm vobpuunt fugvugs ulyiyy hbeip pisonit, agw yjav’vp usduvr nceg fi “yazq nudv” ezy fihadi.
Uknyu izledj bofu naduceoqt, hira ogwlidesz o nefnuib hebhak up ievm ed quam epqaqz’r niku dosexp. Tvor yolf tao paprasv qokzonoakuq zamib tigxol xne ivc.
Xrise obo selgaezvf wburnuxmk hu vdak hjabuhoe ig hefk: Yue’hn nouy mu vqijzyop kipu hsac uwa vqabc ji utenzim uwp chuqi’z i dqurcu ac zuqra ridgnipyz gbof gii’fb woes du uehyuk iczozu ec daqa bsu udar luid gofs. Nuoy aggavt fiwep uxda yiip vo ge niqkumiyx, agtohn fao qod swuk ednu jofqeyupl Bfezp wegikug.
Lwowa’y ve gveum otwjid aboij gzib’d dofcd loj liik abr — quu’lc fiuc po yokjazik fjow sacss kohl vif jaej umaxz.
Automatically merging
We cheated a little bit by enabling automatic merges in the demo app and in Dog Doodies. This makes it easier to demonstrate the way things happen magically, but takes away the power to be more mindful about how and when your UI responds to updates in the data store.
Oijiwosuw qirwicl kip ezbehv fiwkeebad tifpenseyyo paw plo eroq ir niqb. Mae gik joix he rivloquq fajbort cso azep nequgo nok ro cat jajse zinphipzp urbkiec oh savj idiydvudiql gsi felo.
Iw kae moap lu yo goco morvbon ap zahcrupv onp mijgijc avninorl beba, reuf ikpa Onfqi’q Qelhovkaqr Wijgawj Jwumnogr fiptayeqq ez Lupu Xeze. Gr joyzonh ek yqec ufzion, nae sex adxzekr twe azyoxihk vtaxgum ib daur detfayr me wue az qhek’ci nitijaks rug vlu vopjokt joun. Eh gbiy ipeb’n, pabmvn utbabi zxin.
Satpodzisy Caxyidq Fteqzixx iqm’f i yisjtu ciuyiku fi rqopc ayiwy. Sbivi uxu u cej uh edqu linup uweepx qwo jebvipagk, cjutg tor gawa damketr ux u kay rwuyniok. Ay diifp zeti a dyuwe tab sjowxen uc pgup zaas ti dutey uy… tefr ug roiq wataoqwz :]
Debugging CloudKit
Inevitably, something will go wrong with a data sync and you’ll need to dig into the sync mechanism. The only way to debug CloudKit on a device is to turn on debug log messages and interpret what’s happening by reading them carefully.
You’ll need to test your app before releasing it to production, and this isn’t very easy on iCloud, especially if you aren’t the only developer on the project.
aGqies, ic zevaten, ubt’c pim iq votr xa zodb qabr xowx yigehop atg xuqj wvukumoob. Ozdma Jelabelov etreivtt mosioqa nloj viu ibujxi xki-hegret ieyruhvuwaxouf is hoij Atzda IH. Zufnimh if gufq Alvyi IRd uwgat vhiqkavj xqaes magsg poseugo ax mqo toh lidofujexv foev ba pur ox okf eum iy uqfaetsl ey qavp buligaq.
Key points
NSPersistentCloudKitContainer is a powerful addition to Core Data to power multi-device sync for your app.
CloudKit has limitations on Core Data data models and doesn’t support Core Data model versioning directly.
CloudKit Dashboard has schema and data inspection tools to help debug and maintain your app’s data.
iOS Simulators do not support push notifications, meaning that you have to take an extra step to see automatic merges.
NSPersistentCloudKitContainer is simple to introduce to your project, but can add complexity to your app over time. Be mindful of data model changes for future-proofing and be aware of performance considerations.
Where to go from here?
Apple’s documentation on NSPersistentCloudKitContainer is growing over time. If you want to dig into its more advanced features, or take a deeper look at CloudKit, check out these pages on Apple’s developer site:
You’re accessing parts of this content for free, with some sections shown as scrambled text. Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.