Search results for

“SwiftData inheritance relationship”

4,980 results found

Post

Replies

Boosts

Views

Activity

Container Failing to Initialize After a Successful Migration & Initialization
I'm experiencing the following error with my SwiftData container when running a build: Code=134504 Cannot use staged migration with an unknown model version. Code Structure - Summary I am using a versionedSchema to store multiple models in SwiftData. I started experiencing this issue when adding two new models in the newest Schema version. Starting from the current public version, V4.4.6, there are two migrations. Migration Summary The first migration is to V4.4.7. This is a lightweight migration removing one attribute from one of the models. This was tested and worked successfully. The second migration is to V5.0.0. This is a custom migration adding two new models, and instantiating instances of the two new models based on data from instances of the existing models. In the initial testing of this version, no issues were observed. Issue and Steps to Reproduce Reproduction of issue: Starting from a fresh build of the publicly released V4.4.6, I run a new build that contains both Schema Versio
2
0
722
Nov ’25
What's the best way to support Genmoji with SwiftUI?
I want to support Genmoji input in my SwiftUI TextField or TextEditor, but looking around, it seems there's no SwiftUI only way to do it? If none, it's kind of disappointing that they're saying SwiftUI is the path forward, but not updating it with support for new technologies. Going back, does this mean we can only support Genmoji through UITextField and UIViewRepresentable? or there more direct options? Btw, I'm also using SwiftData for storage.
1
0
770
Nov ’25
SwiftUI Sheet view with @Query loses model context
I've run into a strange issue. If a sheet loads a view that has a SwiftData @Query, and there is an if statement in the view body, I get the following error when running an iOS targetted SwiftUI app under MacOS 26.1: Set a .modelContext in view's environment to use Query While the view actually ends up loading the correct data, before it does, it ends up re-creating the sqlite store (opening as /dev/null). The strange thing is that this only happens if there is an if statement in the body. The statement need not ever evaluate true, but it causes the issue. Here's an example. It's based on the default xcode new iOS project w/ SwiftData: struct ContentView: View { @State private var isShowingSheet = false var body: some View { Button(action: { isShowingSheet.toggle() }) { Text(Show Sheet) } .sheet(isPresented: $isShowingSheet, onDismiss: didDismiss) { VStack { ContentSheetView() } } } func didDismiss() { } } struct ContentSheetView: View { @Environment(.modelContext) private var modelContext @
2
0
224
Nov ’25
SwiftData: This model instance was invalidated because its backing data could no longer be found the store
Hello 👋, I encounter the This model instance was invalidated because its backing data could no longer be found the store crash with SwiftData. Which from what I understood means I try to access a model after it has been removed from the store (makes sense). I made a quick sample to reproduce/better understand because there some case(s) I can't figure it out. Let's take a concrete example, we have Home model and a Home can have many Room(s). // Sample code @MainActor let foo = Foo() // A single reference let database = Database(modelContainer: sharedModelContainer) // A single reference @MainActor class Foo { // Properties to explicilty keep reference of model(s) for the purpose of the POC var _homes = [Home]() var _rooms = [Room]() func fetch() async { let homes = await database.fetch().map { sharedModelContainer.mainContext.model(for: $0) as! Home } print(ObjectIdentifier(homes[0]), homes[0].rooms?.map(.id)) // This will crash here or not. } // Same version of a delete function with subtle changes.
2
0
274
Nov ’25
Reply to Mac App Packaging
Inno Setup was a sweet app. I used to use that when I made Windows software. I don't know anything about Filemaker. A quick search says that runtimes were deprecated and removed years ago. Apparently Filemaker 18 was the last version to support them. There is some kind of iOS App SDK that may still be supported. It doesn't sound like this would be a quick and/or easy solution, but that seems to be all there is. After Hypercard, there was never the same kind of custom database app community (Clipper, Access, Paradox, etc.) as on PCs. I don't know what you mean by inherited icons. A DMG is just a disk image. Its use in installing software is problematic. Why use a zip files or pkg installer when you can use DMGs that make it 3 times more difficult? Look at the pkgutil tool. All you need is a folder with the app you want to install. Create a directory tree of all the locations where you want to install files. Then use pkgutil to create an installer for that. Forget everything I said about the Mac App St
Nov ’25
Reply to Mac App Packaging
Etresoft, thanks for the reply. I assure you, I'm not trying to make work for myself or others, merely attempting to package a Filemaker 18 Runtime app. A Windows bod, I had no trouble creating a signed exe using Inno Setup, but have been pulling teeth trying to do the equivalent for the Mac version. I began by reading the official Mac guides, but found them impenetrable, so turned to Copilot and Chatgpt. After many weeks of toing and froing, I have reached the stage where I can script create a DMG, but am currently having trouble with inherited icons. Are you saying that if I had merely uploaded my runtime to the Mac App Store, I might have avoided all of this?
Nov ’25
SwiftData not loading under iOS 26.1
Updated the phone to iOS 26.1 and now the app is not working anymore, even previously approved version published on App Store which works perfectly on iOS 26.0.1, and iOS 18+. I deleted the app from the phone and installed fresh from App Store, still the same. Logic is that on start app copies previously prepared SwiftData store file (using the same models) from app bundle to Documents directory and uses it. Currently app just hungs with loader spinner spinning as it can t connect to the store. Getting this error in console when running from Xcode on real device with iOS 26.1 installed: CoreData: error: CoreData: error: Store failed to load. (type: SQLite, url: file:///var/mobile/Containers/Data/Application/DA32188D-8887-48F7-B828-1F676C8FBEF8/Documents/default.store) with error = Error Domain=NSCocoaErrorDomain Code=134140 Persistent store migration failed, missing mapping model. UserInfo={sourceModel=() isEditable 0, entities { /// there goes some long models description addPersistentStoreWithType
8
0
727
Nov ’25
Reply to iOS26.1 crashing all my live SwiftData Apps 😡
Just a quick update: This fix helps avoid the crash but it does not solve the issue cause by iOS26.1, which automatically changes SwiftData Arrays or Sets attributes from .externalStorage to .transformable. This in consequence blocks the iCloud sync mirroring and results with the full disappearance Customer's data after updating. It is a serious bug that needs to be address by Apple ASAP.
Nov ’25
Reply to CK WebServices getting 500 Internal Error
A server-to-server key is for a server script to authenticate with CloudKit and make API calls to a public database with the inherited privileges of the creator of the key. To access a private database with CloudKit web service, consider using an API token, as described here. Best, —— Ziqiao Chen  Worldwide Developer Relations.
Nov ’25
Reply to SwiftData not loading under iOS 26.1
Hi Chen, I don't believe it has anything to do with Transformables, in my opinion that is some another warning for handling image formats or colors but the image gets through just fine. I've had that warning way long before. I honestly think Apple should hold on the iOS26.2 before they fix this. It's messing millions of SwiftData Apps already published (customers are already pissed). Look at this answer I posted a few hours ago, it might help: https://developer.apple.com/forums/thread/808020
Nov ’25
Reply to SwiftData not loading under iOS 26.1
SharedModelContainer.txt Folks who filed their feedback report may have gotten responses from the feedback system. For people who see the same issue but haven't yet filed any feedback report, I'd like to share our investigation here to hopefully help. To give you more context, SwiftData (with DefaultStore) uses Core Data as its underlying storage mechanism. At runtime, SwiftData converts the schema to an in-memory Core Data model (NSManagedObjectModel), and uses the model to load and persist the data store. Before system 26.1, when handling an attribute of an array type, SwiftData converts the array type to Binary Data. On system 26.1, it instead converts the type to Transformable. This change leads to a difference between the in-memory model and the model used in the persisted data store, triggering a migration error with the following message: Error Domain=NSCocoaErrorDomain Code=134140 Persistent store migration failed, missing mapping model.” To work around the issue, you might
Nov ’25
Reply to iOS26.1 crashing all my live SwiftData Apps 😡
Thanks for the post, can you tell me a little bit more about what is under your swift data? Any changes? I'm not an expert in SwiftData at all, hopefully as you post your model other people can help you find why, however when I see that error I will consider a staged migration and I think, you should also consider a staged migration to resolve this type incompatibility: https://developer.apple.com/documentation/coredata/staged-migrations?language=objc Albert Pascual
  Worldwide Developer Relations.
Nov ’25
CloudKit, SwiftData models and app crashing
Hi all... The app I'm building is not really a beginner level test app, it's intended to be published so I want everything to be done properly while I'm both learning and building the app. I'm new to swift ecosystem but well experienced with python and JS ecosystems. These two models are causing my app to crash @Model final class CustomerModel { var id: String = UUID().uuidString var name: String = var email: String = var phone: String = var address: String = var city: String = var postalCode: String = var country: String = @Relationship(deleteRule: .nullify) var orders: [OrderModel]? @Relationship(deleteRule: .nullify) var invoices: [InvoiceModel]? init() {} } @Model final class OrderModel { var id: String = UUID().uuidString var total: Double = 0 var status: String = processing var tracking_id: String = var order_date: Date = Date.now var updated: Date = Date.now var delivery_date: Date? var active: Bool = true var createdAt: Date = Date.now var items: [OrderItem]? @Relationship
1
0
152
Nov ’25
Container Failing to Initialize After a Successful Migration & Initialization
I'm experiencing the following error with my SwiftData container when running a build: Code=134504 Cannot use staged migration with an unknown model version. Code Structure - Summary I am using a versionedSchema to store multiple models in SwiftData. I started experiencing this issue when adding two new models in the newest Schema version. Starting from the current public version, V4.4.6, there are two migrations. Migration Summary The first migration is to V4.4.7. This is a lightweight migration removing one attribute from one of the models. This was tested and worked successfully. The second migration is to V5.0.0. This is a custom migration adding two new models, and instantiating instances of the two new models based on data from instances of the existing models. In the initial testing of this version, no issues were observed. Issue and Steps to Reproduce Reproduction of issue: Starting from a fresh build of the publicly released V4.4.6, I run a new build that contains both Schema Versio
Replies
2
Boosts
0
Views
722
Activity
Nov ’25
What's the best way to support Genmoji with SwiftUI?
I want to support Genmoji input in my SwiftUI TextField or TextEditor, but looking around, it seems there's no SwiftUI only way to do it? If none, it's kind of disappointing that they're saying SwiftUI is the path forward, but not updating it with support for new technologies. Going back, does this mean we can only support Genmoji through UITextField and UIViewRepresentable? or there more direct options? Btw, I'm also using SwiftData for storage.
Replies
1
Boosts
0
Views
770
Activity
Nov ’25
SwiftUI Sheet view with @Query loses model context
I've run into a strange issue. If a sheet loads a view that has a SwiftData @Query, and there is an if statement in the view body, I get the following error when running an iOS targetted SwiftUI app under MacOS 26.1: Set a .modelContext in view's environment to use Query While the view actually ends up loading the correct data, before it does, it ends up re-creating the sqlite store (opening as /dev/null). The strange thing is that this only happens if there is an if statement in the body. The statement need not ever evaluate true, but it causes the issue. Here's an example. It's based on the default xcode new iOS project w/ SwiftData: struct ContentView: View { @State private var isShowingSheet = false var body: some View { Button(action: { isShowingSheet.toggle() }) { Text(Show Sheet) } .sheet(isPresented: $isShowingSheet, onDismiss: didDismiss) { VStack { ContentSheetView() } } } func didDismiss() { } } struct ContentSheetView: View { @Environment(.modelContext) private var modelContext @
Replies
2
Boosts
0
Views
224
Activity
Nov ’25
SwiftData: This model instance was invalidated because its backing data could no longer be found the store
Hello 👋, I encounter the This model instance was invalidated because its backing data could no longer be found the store crash with SwiftData. Which from what I understood means I try to access a model after it has been removed from the store (makes sense). I made a quick sample to reproduce/better understand because there some case(s) I can't figure it out. Let's take a concrete example, we have Home model and a Home can have many Room(s). // Sample code @MainActor let foo = Foo() // A single reference let database = Database(modelContainer: sharedModelContainer) // A single reference @MainActor class Foo { // Properties to explicilty keep reference of model(s) for the purpose of the POC var _homes = [Home]() var _rooms = [Room]() func fetch() async { let homes = await database.fetch().map { sharedModelContainer.mainContext.model(for: $0) as! Home } print(ObjectIdentifier(homes[0]), homes[0].rooms?.map(.id)) // This will crash here or not. } // Same version of a delete function with subtle changes.
Replies
2
Boosts
0
Views
274
Activity
Nov ’25
Reply to Mac App Packaging
Inno Setup was a sweet app. I used to use that when I made Windows software. I don't know anything about Filemaker. A quick search says that runtimes were deprecated and removed years ago. Apparently Filemaker 18 was the last version to support them. There is some kind of iOS App SDK that may still be supported. It doesn't sound like this would be a quick and/or easy solution, but that seems to be all there is. After Hypercard, there was never the same kind of custom database app community (Clipper, Access, Paradox, etc.) as on PCs. I don't know what you mean by inherited icons. A DMG is just a disk image. Its use in installing software is problematic. Why use a zip files or pkg installer when you can use DMGs that make it 3 times more difficult? Look at the pkgutil tool. All you need is a folder with the app you want to install. Create a directory tree of all the locations where you want to install files. Then use pkgutil to create an installer for that. Forget everything I said about the Mac App St
Replies
Boosts
Views
Activity
Nov ’25
Reply to Mac App Packaging
Etresoft, thanks for the reply. I assure you, I'm not trying to make work for myself or others, merely attempting to package a Filemaker 18 Runtime app. A Windows bod, I had no trouble creating a signed exe using Inno Setup, but have been pulling teeth trying to do the equivalent for the Mac version. I began by reading the official Mac guides, but found them impenetrable, so turned to Copilot and Chatgpt. After many weeks of toing and froing, I have reached the stage where I can script create a DMG, but am currently having trouble with inherited icons. Are you saying that if I had merely uploaded my runtime to the Mac App Store, I might have avoided all of this?
Replies
Boosts
Views
Activity
Nov ’25
SwiftData not loading under iOS 26.1
Updated the phone to iOS 26.1 and now the app is not working anymore, even previously approved version published on App Store which works perfectly on iOS 26.0.1, and iOS 18+. I deleted the app from the phone and installed fresh from App Store, still the same. Logic is that on start app copies previously prepared SwiftData store file (using the same models) from app bundle to Documents directory and uses it. Currently app just hungs with loader spinner spinning as it can t connect to the store. Getting this error in console when running from Xcode on real device with iOS 26.1 installed: CoreData: error: CoreData: error: Store failed to load. (type: SQLite, url: file:///var/mobile/Containers/Data/Application/DA32188D-8887-48F7-B828-1F676C8FBEF8/Documents/default.store) with error = Error Domain=NSCocoaErrorDomain Code=134140 Persistent store migration failed, missing mapping model. UserInfo={sourceModel=() isEditable 0, entities { /// there goes some long models description addPersistentStoreWithType
Replies
8
Boosts
0
Views
727
Activity
Nov ’25
Reply to iOS26.1 crashing all my live SwiftData Apps 😡
Just a quick update: This fix helps avoid the crash but it does not solve the issue cause by iOS26.1, which automatically changes SwiftData Arrays or Sets attributes from .externalStorage to .transformable. This in consequence blocks the iCloud sync mirroring and results with the full disappearance Customer's data after updating. It is a serious bug that needs to be address by Apple ASAP.
Replies
Boosts
Views
Activity
Nov ’25
iOS26.1 crashing all my live SwiftData Apps 😡
Apple WTF? What did you do to all my Apps? none of them work in iOS26.1 (all worked in 26.0). XCode simply says: CoreData: error: addPersistentStoreWithType:configuration:URL:options:error: returned error NSCocoaErrorDomain (134140) * SwiftData is supposed to do all these automatically 🤷🏻
Replies
4
Boosts
0
Views
302
Activity
Nov ’25
Reply to CK WebServices getting 500 Internal Error
A server-to-server key is for a server script to authenticate with CloudKit and make API calls to a public database with the inherited privileges of the creator of the key. To access a private database with CloudKit web service, consider using an API token, as described here. Best, —— Ziqiao Chen  Worldwide Developer Relations.
Replies
Boosts
Views
Activity
Nov ’25
Reply to SwiftData not loading under iOS 26.1
Hi Chen, I don't believe it has anything to do with Transformables, in my opinion that is some another warning for handling image formats or colors but the image gets through just fine. I've had that warning way long before. I honestly think Apple should hold on the iOS26.2 before they fix this. It's messing millions of SwiftData Apps already published (customers are already pissed). Look at this answer I posted a few hours ago, it might help: https://developer.apple.com/forums/thread/808020
Replies
Boosts
Views
Activity
Nov ’25
Reply to SwiftData not loading under iOS 26.1
SharedModelContainer.txt Folks who filed their feedback report may have gotten responses from the feedback system. For people who see the same issue but haven't yet filed any feedback report, I'd like to share our investigation here to hopefully help. To give you more context, SwiftData (with DefaultStore) uses Core Data as its underlying storage mechanism. At runtime, SwiftData converts the schema to an in-memory Core Data model (NSManagedObjectModel), and uses the model to load and persist the data store. Before system 26.1, when handling an attribute of an array type, SwiftData converts the array type to Binary Data. On system 26.1, it instead converts the type to Transformable. This change leads to a difference between the in-memory model and the model used in the persisted data store, triggering a migration error with the following message: Error Domain=NSCocoaErrorDomain Code=134140 Persistent store migration failed, missing mapping model.” To work around the issue, you might
Replies
Boosts
Views
Activity
Nov ’25
Reply to iOS26.1 crashing all my live SwiftData Apps 😡
Thanks for the post, can you tell me a little bit more about what is under your swift data? Any changes? I'm not an expert in SwiftData at all, hopefully as you post your model other people can help you find why, however when I see that error I will consider a staged migration and I think, you should also consider a staged migration to resolve this type incompatibility: https://developer.apple.com/documentation/coredata/staged-migrations?language=objc Albert Pascual
  Worldwide Developer Relations.
Replies
Boosts
Views
Activity
Nov ’25
CloudKit, SwiftData models and app crashing
Hi all... The app I'm building is not really a beginner level test app, it's intended to be published so I want everything to be done properly while I'm both learning and building the app. I'm new to swift ecosystem but well experienced with python and JS ecosystems. These two models are causing my app to crash @Model final class CustomerModel { var id: String = UUID().uuidString var name: String = var email: String = var phone: String = var address: String = var city: String = var postalCode: String = var country: String = @Relationship(deleteRule: .nullify) var orders: [OrderModel]? @Relationship(deleteRule: .nullify) var invoices: [InvoiceModel]? init() {} } @Model final class OrderModel { var id: String = UUID().uuidString var total: Double = 0 var status: String = processing var tracking_id: String = var order_date: Date = Date.now var updated: Date = Date.now var delivery_date: Date? var active: Bool = true var createdAt: Date = Date.now var items: [OrderItem]? @Relationship
Replies
1
Boosts
0
Views
152
Activity
Nov ’25
Reply to CloudKit, SwiftData models and app crashing
Issue resolved: using the @Relationship macro on both sides instead of one is the issue. After I removed one @Relationship macro from one side, app compiles neatly.
Replies
Boosts
Views
Activity
Nov ’25