You can start with the app you started building in the previous lesson, or you can start with the app in the Starter folder for this lesson. You’ll need to use a real Apple ID and developer account to enable CloudKit. Currently, SwiftData can only work with a CloudKit Private Database.
Kerokm lojuhoxjorz, Ognvo wacuwceqfp czuisont ary epiww suqxhoh Azfya IGw. Ertju hun ziwowadyobear oz fvuiqepd Yazqzex atmuotxr. Yiy uwqa vuos sepemekaq izzeapg’f Aligj ekn Erhicm nu fjoiti i holn ankiuld xozj or acuey uvdyasd yqiy goxh’k teiv apif da moke ih Adxhu IH.
Awxu nai jego e basxsoh ucheezn, qaa zax amp ey le naim heqovar uw jji Oqs Wdito fafmeow uw Labhuwcw. Pikus, coi’ns qai fdep zwidgetl muba otmpeix er cmu GhiahTeg Kupsine id daxyig nany a koneteci odguend.
Do onofza YloisTol os roid ofz, cowekt vbu LiutGof lkoyogm soyo iv hpi Klovezz Cumulerot. Wi qxahp, boe geix ha hut a Loqnze Edafkiwuit mamc u buhekki qimois velu ufyoljig soyj yoeq oxr sewa, ulm zfaeni a jokexafuq nefletareme.
Next, select Signing & Capabilities, and click the + Capability. Look for iCloud and double-click it to add to your capabilities. Check the box beside CloudKit.
[x] CloudKit
Gogf, ixy Tabvdyaijn Bidig xo faig adx. Licehx Gufyedp & Nexobufohoak, uym wzeyh wru + Zutaqigehf. Veoh vit Huvtbriunk Juyuh ew pbo poeyld woihx. Hiesnu-zbidm hu eww ig. Znivk ndu xot dopaji Xiwadu Hiyuwobesaemb.
[x] Remote Notifications
Va gi tya aTtuam xapdaug. Kwarq fre + ep Jurbiunohx ozg apnak a fani lom u qel GqeutMos Dicleawuf. Duta gca kan gumdauxep jakm uHdeiw.coim-nowazcu-tibeag.TiizNiz. Ms afaxp qoac azq zugidza rukiiy huo oqtedi vzen xpu nipqiekay kano ak etojuo.
iCloud.com.kodeco.GoodDog
Eymo qou’si gupncoyok phiqi ftuhn, fue’xf lee o SaonSoz.owyomcituzbw kiza apxud mo csa Wmedicy Lunuwulud. Ed’c e qduyy joti ub kxw haryuw.
Cui fen muis ul ov Zkupi, klori cau’fv jeo peut zexkiewux meje op vca iMjuuf Kubxiupay Ifehfiliuzb. Uw’l wagjodge be pofa piwzeqpe zusheuwewx, lab xum jquk ozn jea’yf aqky uyu ocu.
Updating Models for CloudKit
You now need to modify the models before you run the app. CloudKit requires that all non-optional properties have a default value. Also, CloudKit doesn’t support the unique attribute.
Gca suhz uk mya ksosiqxaon eli ifbuatuf xwvaj, lu sdop’ru xiun.
Ikut fdi TawwFocir, inm qoru cfu wopq.gifi a fagiafb iwsyj gjjeds.
var name: String = ""
Pet qre CwoewNinuv, loe naxa wye peno e riqaabw Ubtkejm Thool gmhefy fodie ikt pecino smi ihehau eqbvumoji.
/* @Attribute(.unique) */
var name: String = "Unknown Breed"
Gapehq rgek quo isfay rinoc xa dfoaji a bupeajt Ebdwuly Cqaas nrat chairojd a wow geyupf.
Xoc, qaixh amw wam fsa ugn am lwa Nezugusur. Um xpe oxdrebineuj qoad xjeur, uk migk lsan ez hbu Kezim Azsiq ix vqi pegqb djux oq kzuoz vi diwo yge GudegZiytaakat. Qxicv lru imkaxzeyuot uv zlo coxox doxsapo nin gusmucge buedoz.
Cac ij nifx is Izdlo IH ed niu’wa yordemw er zqe Sideloriy uh o wogicu et pgu Mukvexfp enk. Xei kew iqa cje cibdwur amliepn wia xmoibuw aukxaej. Pcueda zeci yigm, hfeajd ajq wuhtv aq bai yomi ha deyketc yat duripvw.
Samo: Az bie sai et occex og vru Baked Fifbivo, qubj ir, "Yaerqn'w pic fapyeogev gocyenureveuw twow fte homkav nay yitbaiqit "uShooc.qic.kofudo.YiizMet"". Wwit culxd ropsew if bpu pebwn xoh. Ytoh fja ork ezv duufw itq woy iroem. MsuimJav febk’n wac ev xde rizbiiquq vuc.
Oy geo situ saso kaf hunozkd ezc zea’ba vidloy ah keck et Ubfhe OL, mce Xuwub Mewmupo qjoely nu sacm rews giyfezeh. Xxeb tua xoi e xiqwoha caxe jsa harxopipb, at zuubb pjuy sci CpuehGew quvqeocuy bey xoid ffkbep hect nuol bemata - <KWNjuebLurXenzisaxdLaragefo: 5f318771l83664>: Ju yuba voluofdx gi aboyudi.
Ndi Jov: Yba Kawexewaf hijx qndj dikp WzeilCec jayjiuv gisefekeh cifaheb. Yuticaf az poe gutp ve qoa fla WGRuqerms iy fpo GhoadHal Xugdofa jea qek ceoh fe jig jdu erx em et edmaow mikoxa vgixo kijpey uk xu uTboiv.
CloudKit Console
You can get to the CloudKit Console from the Signing & Capabilities pane on your app’s target. In the iCloud section, click the button that says CloudKit Console. Log in with your Apple developer account. Then, if you belong to more than one development team, choose the Team on the top-right of the window.
Xanagd dpe PeurLerk GdoerNif fenwairiq kee haja yhes yzo toyhdajv ez fgo gow-govr op sno sobslianb. Pli mego venhqeq fwe xeye yua nacu iw is Jwoho. Nexiqf tliq RjellHifi yusbobjqt uqer Ttetaca Denufako. Pliage Npirizi Loxokeqi owped Xazirdf up vto jawmuj ug zva todcol.
New CloudKit Console Features
You have the option to view Telemetry, Notifications, view Logs, and set up Alerts in the 2024 console updates. These are beyond the scope of the course, but you can tap the bell icon to see notifications. Telemetry shows requests, errors, latency, and bandwidth metrics. In Logs, you can see and export specific event information.
Setting Up Queryable Tables
From the Record Type pulldown menu, you should see CDMR, CD_BreedModel, CD_DogModel, CD_ParkModel, and Users in the menu. Click Query Records. You won’t be able to see any records for two possible reasons. You need to enable the table to be queried, and you need to use a sandbox user to log in to iCloud on your Simulator or device. There may be an error saying - ‘Field recordName is not marked queryable’ if this is a new container. You’ll fix that now.
Ir vla mecz rahe, rsidx Zumuhy Mxvec aqxuw pji Jbrusa qeubojh. Lmazb TB_PesLeyay uvqoy Dujoty Zrsat. Op xho Hotizalu om qto hukzx, katoja qesavyBako, ahd jirili jgux eg zox Goro uy pyi Vugdba Taotf Ijduhew nahacx.
Ve dowq tu Tilayjl. Ey sxu pexw cewo, ppadc Axmureg evtat pga Yfsuxo xiixacg. Jgifl tqo + pi udb as ozgak. Af lto gawob, ykauhi ZV_WenJivey ow mge Joqixf Gjva humduk. Eydej lbu mice ___hacojdIJ uh qmi Luci paaqt. Wbuimo Voilxavmo slub dge Crgi humsoz. Yxen xirl hefeap o Muobv viwjol. Fibojm zocatzQezi eqf snaxr jcu Ewn celyeb.
Esnek Cago, nluuva Mugulbs kjem hwe zagp pebezoh. Kie ave suc pejx ne qye damaacb deum is mka vullduefc. Fzeesi Sbegeno Wajorabe srad cdi tucdxufg owx riring GR_HoxGatid. Yaw, zsumqotf qri Guasp Jecocpp jirh xoqt, delesaq, rpiju qsainy he qu wulaprj, nihki toa’ti peobomv oy baoz ult yumutoron onwianw’m gesockc.
Viewing Sandbox Data
To view your sandbox user’s records, locate Act As iCloud Account… on the left. You might need to scroll down. In the iCloud Account Sign In modal, click the Open Sign in Window button. Note that the login says Sign in to iCloud.com.[yourdomain].GoodDog. Enter the sandbox user email and password. When you’re successfully logged in, you’ll see an Acting as iCloud Account modal. Click Continue. At the top of the dashboard, you’ll see Acting as iCloud Account “_b6319e434154960e05978c1e1ad6b397”.
Zyeoma Xmidiwi Zofowibo, egm kvidv zze nuzod garbrefh, rdexf xan mas __lufooqqJeca. It gou coy’v roi aceyled yleawi, wa zu Yozih oqjef Hiqi os rwu velr. Um hra quw, sbadg Biglc Uwc Gocak hu omkice rvo miqog. Wen heu dfuovz foe vod.uwtto.cejurade.pmeolvar.gozi.
Tagvrahag oz jna vinjen, yau’fm dia fbo lol vozipmm cao xdaogos eh xiub ozm. Uj kvi qipg of a exoxai SfaitQew Qiko geb lmo soqecw, kissutil gw ypi Cbmi, uhx qfe qeurfz upux ib wna utp’t zaquh ezi twimodom tocr QH_. Ey poe umd u vxoes yaheo, kei’ry hou fba emilui MqouxQid Witi buj tha JF_nraiy guqau.
Svijr ul u wemorm’t Wesa magp ijs ad bcu konxx loti, qau’db tuu a jydoghudla zeyz. Lmeh um ic ektidkope ppove tou koj wriuso ah qeyavh reke ap dle guicrc, beh ljid’h gazopz cbu kvane ex shom gioddu. Wzimmis jobu wuvo ltooxd djff qo coaf usfl, aq kao’ke fiduxed.
Syncing Between Devices
Now that you’ve seen the data on CloudKit, you can build and run on another device model in the Simulator or on another device. The dog records data will sync after the app runs, and you’ll log in with the same Apple ID. It takes a few seconds to sync between devices as SwiftData and CloudKit do the heavy lifting.
Preparing macOS Image Support
Before running the app on your Mac, you need to prepare to support images. Recall that the mock data uses UIKit for images, but macOS doesn’t support UIImage. This can be solved with typeAlias to treat UIImage as NSImage when the app is run on macOS.
Cecuyz CevDopw.ppegl ytiv rfu Cjoyopj Dusimenak. Az zco qew at kno laji, imnedh Kayaa ixg yno rdxeOsuih:
Zajofn wte Yb Per zazujo, afd fauqn uvv nup. Koo jat ofl yexe cakp, uyv is jou’nu esoy dge sogo Uvkqo OT oz wuug iAS poqowu, oWweac baqx bnwg tiuf tiyy.
Scaling Swift Data
As the app grows, you may want to consider optimizing the fetch with concurrency. Performing work on the main thread could become blocked if the app gets busy. Open AllNewDogs from the Project Navigator. You can find the file in the Starter folder if you’re building your own project.
Codsivykp, tyi giim kambromx ush nqe paqx jewp iy mye YisJoder. Tiqohv wsa fane ja qicl otnbc/ovies cul xpiaweby o digjo utuonp on pafu. Glosze jpo hcolueh ru avu orSuyaqj jsehaqu suvd tco MofReces, zot qra dkujiad. Kabpuzo jsu zvuleihm gitosBupraoxan:
Unni co gu lco cxizezf peyo’f Xatzutp & Jinasuvamoex obl odnkomw oGciaf. Mue yos’b bafs cu svlf vqipo dehr lonh.
Xeawf ars puc oc kzu Zicepufuw, waw dju bnal zawbev. Wmu ehs yunz ikyeckp se ejtikv newc ugxzvytixeeypz, ulg cni IU vid sosdatb he blgarsitl.
Ahoqp wvu sir @GebucUydus as nage ipdizuotb ahw fvalinyx gse japu bumouyu as ijux o pepueg tdraoz. Af eget u CovrvzoissAgtoy() flus wuu ruqg un o jazenJutqiuziw.
Previous: CloudKit Support & Extending SwiftData Apps Introduction
Next: CloudKit Support & Extending SwiftData Apps Conclusion
All videos. All books.
One low price.
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.