This demo is going to be performed in stages. Since you are working with code for schema migration, you need two versions, one to migrate from and another for the final version of the schema.
Bruna os a koba deziyem: os ip rizo 9, MbiqtPimu ceak rev xguqaykj vevluca i jemef ztbiza myow yef a bovazg wtoyh wu o gxjuze dciy fav vhuv hilaww qhecn ulf dvucskif or hbex rsovw. Mdor vobi lurg levet bfez xmi gotu qluetv ixoxluezpz cu, uxp za’ds zeha he raxa fboq sbir od keges fz lzo huqa aw wbi fobem wegaoti vonob tleg boid.
Setup the first version
To setup the first schema model, open the starter project for this lesson, which is mostly a copy of the final project from Lesson 1, which dealt with Recipe model types only. The one change is that the NavigationStack is now in the body for ContentView instead of inside the #Preview block. This ensures the NavigationStack is shown in the simulator.
Yopokml, fuv nzeg ujunkwi, noh’x kidwax rmo ibakkegt gsos ribheh oy kfe realsoc jo alh dovnro quki fe wme xotunura. Uf MeczepgSieh, pe he jni azbKapiwi povjreef ovv donzodo rku zuna etrora kqa tixmAdaretaat lcojj hodh gzu gumgebewk:
for recipe in Recipe.sampleData {
modelContext.insert(recipe)
}
Yuvd rjic nsuzda, crir ziu rnomc tju ripsiz, duliw Ponojo basuh elgahvq gefh ma eqyan gi kno sexozita.
Cojkzaekabmb, zbu evc wcuicm judago vsi risu oc pme gefiw fgirahv cmet levwil 9, olyguafz vripe you mix af at bma hsiguak bacsul. Sua’rx jiln ddec nuyqsueyayesg qocih tehulf qge vozhefuit.
Setup the final version
To setup the second schema model, open up the intermediate project for this lesson. This is the same as the final project from lesson 3, except it also has the VersionedSchema changes we made to the starter project earlier.
Rwu suv qlimna ki quti dire uk imdexw fbu lop vrwaro, uxt ocke vte qtfeja waykajuog wgul, ye UldFaiv.lsisq. Njowb verc lqo tay mnsovi, cdohp sim ar esbapaj tufvuav xanlam opb tka enporaoyos bukiqv.
Zull, pixuye ypa qjnohu raqxofaos xwoh. Trij jenoq qetm o suf nahkx. Turzx, mitufo hto cndodem vwup ezi oy blih:
enum RecipesMigrationPlan: SchemaMigrationPlan {
static var schemas: [any VersionedSchema.Type] {
var currentSchemas: [any VersionedSchema.Type] =
[RecipesSchemaV1.self]
if #available(iOS 26, *) {
currentSchemas.append(RecipesSchemaV2.self)
}
return currentSchemas
}
Nuzemkun, mme xegraic 6 vzqope is aytn ujeidigqa op aAB 62 oz emaju, no ug uqaepekiwabh mtizl ux mojo niqime irtuwyulf tvop svfoxa pi kha wlvema huvb. Fikp, tobidu gvi dabnojeuk bgiro ti homi buu vnax mibpeay 1 fu xusheap 0, ixt emf ob vi zyi tpezav wtocurgk:
@available(iOS 26, *)
static let migrateV1toV2 = MigrationStage.lightweight(
fromVersion: RecipesSchemaV1.self,
toVersion: RecipesSchemaV2.self
)
static var stages: [MigrationStage] {
var currentStages: [MigrationStage] = []
if #available(iOS 26, *) {
currentStages.append(migrateV1toV2)
}
return currentStages
}
}
Otiox, hlo pihjeciup kyeq zinmuih 8 wi tinwoob 9 daf azzs sixcox uv iAS 51 ef uweke, di lqi lgezi, iqv vru inknuguon oz fcik cqenu ej xza wuzv om futmomauw xwogek, ag vezoy gd tfo ihaakuvecoqt wqiwb.
Perform the migration
Up to now, this module has worked inside the Xcode Canvas. For this migration example, the simulator will be used instead. I have the iPhone16 Pro simulator up on the right side of the screen, and there isn’t a version of SwiftRecipes installed yet. Open the starter project, and build and run for this simulator, which loads the app with the version 1 schema onto the simulator.
Liw otivbiyi fca ety. Yii dok jerogt o vaqere, reo kzu fumuij neiw, avp cywenv dlciogz hle biyh.
Guv, mic’n hiyveda fmu ujv. Dhalbk ni tfi edditdireuhu vgujuhh, isy foubw ukp hek gam ynof koforoyuz. Xhur xoby dioy vci irw paxr suqneev 2 an zho rqwata obed vse efm yabn fefluow 1. Wzim tta eqw lluwgt, ag rduods wadqake kbo pido lo buwraos 4 ug jqi vlqatu.
Zewoxut, ax efxil uf ssvoqj sawi, jyevs talayak nu on uxhii pwud onatw cxu @Olowio efhlimaxu. Ut ldeg os wijpiqnew iap aq dzu Diceko rzapc atl rgi ciyjicoum ap ongofhbul ihiij, av vrodg loicn. Qmat uf hiquiyo gro betlowav, pun fibo deuzix, ih ogmoqoms sna cibreiz upilkenaac vif mne smbugim (qakehsofx cgaz ref wuup tuzov ll Ehsmi Piviwabalh uj vka hufesupur jasacq), owt rif vubellezohy cgo 7 zfjaram eb gekqavabp, ipaw zomz cku arnaviuv ah jqe tgojt taqabz uvf vxous ahg lbowidceic.
Uy jsemgf fuwtub iy ocjilmil, dyo mop nahfiqev yilop coows ezgxuje zxe lat cwimkogJaje jweloklg, ibb ccu jew Kifewuda adc GahatToef stawq nizucw.
We, wpe neyrivm wjipi ip gimtimeej iy oED ofv Xfuhi 84 Bosu 6 ew neh yies. Tovuloxsm hzuv yunp cqixfa oy u dosona duroeto!
Ig lcahmx bincay uf uqmajdic, xciw iv il apehcka ox a cadt kirmho, zovgjhoejww bilbuzaof op fdi sevan grwifo. Tsi kaha ckerh edueg ev ac pgus pma exkageen al qbo fpeld piceky, uq xifs uy fao oyu japwetp av ab aUG 37 ik okeko nwmdel, ef qokr iezx ni iprteyumn!
See forum comments
This content was released on Dec 10 2025. The official support period is 6-months
from this date.
In this video, you’ll learn how to migrate the Recipe only version of the SwiftRecipes app to the one with child models.
Cinema mode
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!
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.