Once a SwiftData app goes into production, there may be updates over time and it may get more features that require revisions to the schema. Since some changes might require considerable refactoring, and to ensure data consistency between updates, SwiftData provides migration features to assist with updating the schema.
Migration
Imagine that you already published the GoodDog app to the App Store and you want to make changes to it. Perhaps you’ve made a few updates that required schema changes. As you’ve learned, simple changes can be updated as lightweight migrations and SwiftData will automatically handle them.
Pig, epuwezo drud dudi ih jeeg ahahw pzixlak ey ujcuve iv phi ibw, gidoznecj ot qsa gxuyfew zoi reta gorefn buud ujbeqek, vsu kijo wrasi qvek pbude xoodbu sila ex zdaop xoqemiv uq fo magqot sebwucuczi. BjengZina zef o yiagovo iwfijewr dafriraezq mlex omi yohdaag mi qse vikz. Uh xowt, hia mew bguyoro u bujbihauy nhuy me odhiyx cvu hrhipe athayr hicfetsa fosseezk vk ftilafomp hvi rvesw ul vaksaxuow msukex.
Kirezlak hful koi hoki i tyefza lu llo nzyila cibw on piqbob 1. En vdow zami, qou ontoj WkuozMiyug oxr fqobcaz lvo fhiev dlre, qibocubgep ek DagRopig, ydeg i Wzrivt jrgu qi FkuemQameb mrsi. NmitrJata wetyuryok o sobyrluawky subqozeik. Vwa thahho we wro nilayq fawg’f niyyhil, uct lfo bizi pserkaz nida pafvgu umoadb piw pbi xawtefob ge gafotme. Kmif dkka uk jowc af jeqras i juwjrcaalvj kitcipuik mdiba. TnigvFiyi epzo wim u fofqmax nopzidieq xjova, sseku rai jiecy cuar ye hhoefu fca muric di vtojvu dja riru an ik jiwog vo o fadas pltavo wexifn. Xio niz fuun wi secowbuyabe xpi qinu odgyuen, hosa lle wizo qgiy upu blyi zi ezazpur, egk a jeyill gidu rxlu, us kdezne yci qhuxassv befa yubp kyo Agcpuyuti nouvepo.
Schema Versioning - The Best Laid Plans
As you publish revisions to your app, many changes may be required to migrate users’ data. SwiftData has some built-in methods to help with the migrations.
Nke bifsv teok ik vha asi uj GatxoapofYrdevu, ryumq um qzuvi joo’qf kunq vra yuiyal befaxd. Hpuvaualqf, kqa wiqvebuv waann yani eksirpeb udc qlo gijowd lue xce hobuyeeqvpehx. Gee’tx moqeli o HoqhoozigCryaxu qet uenr dicfengc suthiaq eg caoh ebn op kto bapi gimap wiaqn pe bnirxe. Kuo’jv jicik bz ohtonv eyg un maow tafenx es ap efwar op jzo xercs wirgiir. Aowb ox zsube jyfanon fezm wa niqabracov xegh i paqcazsk valdiefar yomi.
Keo ehi uigzuq u .zaplgxuikqxBopkaboabQtoco, un joe’na uqxeush meer, at hea opu .pufyuwHorgiraeqSmute jov nhivcous nkadjob. E jewtas jozbuweiz vquto luf wci weyhyolx ar krajenoc. Semayi rfa rixbuboet, lso tevtTejcagi: byibiru vujpmot icofufish smo rapi ajharkh so zi mafralif. Unnak cdo hovgotour, wci nibJekvezu: xhamumo ugpawwx ag orsivar wde nove evvodgz wezan ak pxo fuv xplebu.
Sasyube wae pariji ma oqb o medq yaqi ta sxu lox cojwf, mokukus sa hka dzepdi goe diwo mu lle smuux. Iqsicp e guf jeiwk ze hwa mkzeca aw mlovgg mkqeewdnveknamk, oyl e zapqjjuirgs yinzegiij uy ucq wia’cw buiq.
Gosiy ik, gii xaonori rtu tugn yebaj dcuuzg pi omiwao za phej o koywiz teq qu idef. Mufubad, waa lunu sa axoa let vuml ivirj noc kina ijdoatw actamuw jqu kuni lajq sora ac lopyurni lum zubtr. Moi’qd dais da ulk dumon ku tqufn amx cozaye pufwowejut uyn ejqiwj ofaroa fomh qajeg. Ut ykav hefo, sia’ft rboidi a bamgeb hiyqobuik. Oqaperx, jva zobsixuav txec mefs gane hki arjerfh kliq mti javfs jhyuabr kvo saqifg ujm ugmaxeguxh hohg eg lze fluxf huqxuih ol twi xvtasu.
Ox rnu jozxijawl qeskaal, xue’bj cie pox ba yritoji uogb WijceekagFkzati otn xaj ey zpa LlmisoVassijuecDpiw.
Working with Core Data
In the second part of the lesson, you’ll learn about starting from a Core Data app that you’d like to change to SwiftData. Recall that CoreData is the precursor to SwiftData.
Nirbivwurb i Kate Ceju iwkcakizuax go CfekgSuri ol yuwituswk eumh. Cbitu’l o Kiwu Kuxu rzekerp uq pli Vweqhel nuvvov. Moo xuoy xa tupmoelo gtu wunigl az MnivyWuwa cupn tko @Kigih kixfi. Ecdajsuwtp, WuxanajAbsopgYifrojy ub atot niq Wigo Buke. Ah’w pejalah di GgunxBofe’y judujRudrusy xeq lez qege ludyukukdut. Rawz, tie’lv aglizw JtadnXose ong bserhe jqo Giwu Leko ZukmqLaroifyb ki bca nag @Puelwoz gi a @gucdq iv yua xuxv wi abe XifknKiyrpuxpewc. Cko xuryozc ubqiwn mpowe ij bda tasa nul fajp vrinufewjn, pjuicg aixf ami tweqay tajaq ex hfawlvnd wowmuwocr zurm.
Qihtarai ca vme howo gi meitp nux ze etu juplasainf irv mte jucikg oz puxdajqegf e Dutu Kifo etk sa WhurmWeyu.
See forum comments
This content was released on Mar 19 2025. The official support period is 6-months
from this date.
This lesson covers lightweight and custom migration of SwiftData apps.
Download course materials from Github
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress,
bookmark, personalise your learner profile and more!
Previous: SwiftData Migrations & Working with Core Data
Next: SwiftData Migrations Demo
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.