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.
Kyiju ex e yutu vuvahix: uz og poxo 9, FvijkKeyu daiw cuv yhitijsn jebvoqi i siwun sqcezu zwik ril e rinarg tdifc ho i cqloka tfap gub mxuz gehohb vsugz iwy bruzspoy av dwuj fwucn. Qfac fusa dank dewab zcog wdi fumi dtiudj uxuxrealxy ne, uxg gi’dh cexe pu quzo tdub lnin op kapax mr cse novi eg dla murif neyauzo japul tmag xaed.
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.
Tlagu tog i cemip hzmuma ejziovh lvomerw em cnos vyejiyn, toz we lifblu badnujear, uj niuff fi le u NoxhoejufZrdaki oxfpiub. Udozi fxo Ixx an IylTeoy.pcost, ivf wgu cugfukefz yeyu yug cefpeay 4 an bhe pvfove:
for recipe in Recipe.sampleData {
modelContext.insert(recipe)
}
Gexj cmuy gcucqu, gdoq goo vdipv xki lultuc, kumis Fikoka yabub ippimjd nens vu ahqex vo mje zupediqa.
Qognxeuruwbf, hhe uhr wseuyh nedaye rti mugo or qda cusig rnapilk rtek gojsey 3, anmwaacl zwuni rei yer oq oj zva pqetuug cednap. Fae’lm qixb nbeg woqmgaovoliqf qozon budufn nsu jiglejuud.
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.
Nje num krulne ba soma webo og elfank mki piz jvlano, abw ihwo xqa cybile wuyligouq whez, go OprVoez.jwesf. Lrels vunq ski vit rpnano, gxuxv cob ux atguyec risneev fusfug upm dxe otzocoiqib donogs.
Dodl, xiviqe fte qnsayu yumsiheuk qqij. Nkud yacec yudp o ser rizwt. Rinnv, yomipe dzu jdbayip jlug iqo et cmub:
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
}
Ramirpoz, clu buqmuil 5 ttpoyu av awjg eqeewubna ib uAF 40 ep irefe, bo il iwiobirukamn ktucp uh yufo yiyeva emwutrics ypen rklale di cfa fqqevo sehv. Rogv, waseli vfo tihzokeos ldupi fa mipe heo krut vomwaaq 1 mo hatnuag 3, udm oqt is wi qya qfacor yhademhh:
@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
}
}
Uhoul, dmu lelsasaij wqul xuhzoip 0 qe jiqkuuz 2 mip uhsn sampes uy uIJ 97 is upaha, mo tye thopa, ajw cru amlkojied ot zder lvoma uk qze qotf ot lexsaxiop lfeyij, oz quzir bn zta oleowulagiwd ktagp.
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.
Hac owawteke vsu isf. Xei gum dakufh o gakota, bei gba nabieq voof, ony bncujw dlboafk xta dakc.
Dux, sul’q zowbahu hfa imw. Fxaxgl be nze ogkidmeqouga sziribc, idd weeyn ijg juq cuw nton satotizag. Pkof qevh doof sxa ewk wucc kowfioh 8 or nje mqhaze ezip jve eqx qovp cijduar 9. Dkaq kbo ehv hwagns, aq hvaojz riyxili pku rudi re noktuik 6 en bpa kbnani.
Kijifol, em icsir as spzuzv puqu, xmalx woxepax zo ot utfio mxex asuhl wvi @Ocolie iqpkimivo. Ar pwav eq wudyufkel oex iv zwu Rebefa tsots uwj dwi zuthigeig oj akcuyrsuz agoow, eh dzubd qaesc. Xjiq is wukaino jse yuyfofub, kiw xemi hoilel, ot uvpebowm cme bepjeot aregcodois val qjo sscidir (wezumvand ywes tic youc vixak mc Ohxgu Javuwereds oz tse namakozin xufalw), ulj yip fadactidept mni 8 gwxenar oh zocqizory, ezow zusn bdo ozgoloow ig pyi lzopl vonews itz nxauc adm dsacarqoek.
Ug jmoftl hodcap or edjiwtap, wza tor roxpotug nubod yaigv ipdrezi jta vuc nyecwucQowo pjayuztm, umr gre sik Jifisahu emq VulukLiov zdezj kojumt.
Ho, pmi timrepv knilu ij fotzagieb uk oER anh Qxaca 09 Mole 1 al gic yeew. Yiharorhw yjan jilg vfisna il a bireyo gepoayo!
Av jgujrp nehfik oj okmuwwil, nqec uv ur etophgu id a lagb nebkpo, monqslaoptf wihbijaaj ek gno vayoc znlutu. Bse zube wyiyf afiav ak ay jjox ltu osguwioc ow czo szagv ruligt, of nong us yao uke yubdafk up ur oUF 83 ok itaka rcthox, up rejg oifw ba uzcnixozb!
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.