Search results for

“SwiftData inheritance relationship”

4,982 results found

Post

Replies

Boosts

Views

Activity

Reply to Multiple Executables in a Single Bundle Fails to Launch Others After Codesign
Getting back to this! Thanks again or the detailed response. The ugly truth is we need exec_b to be run from exec_a and by thirdparty tools that might need to call up it's UI. Think of exec_a as a sort of launcher program that orchestrates exec_b instances it's called up but so too do other parts of our pipeline, potentially. [quote='831858022, DTS Engineer, /thread/778169?answerId=831858022#831858022'] Add com.apple.application-identifier and com.apple.developer.team-identifier to your App. [/quote] Where should this be put? In the entitlements.plist we use while signing App? If we're to test the .inherit entitlement to just get exec_a launching exec_b, you're describing something like: # codesign other binaries... (macdeployqt does much of this work) # Sign child exec codesign ... --entitlements=./entitle_child.plist .../exec_b # Then sign the App (including the com.apple.application... tags) codesign ... --entitlements=./entitle_app.plist .../App.app Apologies if I'm missing the mark here. App val
Topic: Code Signing SubTopic: General Tags:
Apr ’25
Reply to CloudKit not storing or updating public data in real time.
interferon, thanks for responding. Doing another google search for answers I learned that SwiftData and CloudKit only do private databases. So, I need to wait for the next best SwiftData update in order to have a public database. I can wait. So SwiftData and Cloudkit are not using public databases at this time.
Topic: Design SubTopic: General Tags:
Apr ’25
SwiftData document based on iOS18 shows blank screen
I have some apps using SwiftData document based. They work as expected under iOS17, but not under iOS18: install the app on a iPad 11 pro (first gen) from my MacBook open the app and open an existing fils (perfect under iOS17) it shows a blank, white screen, no data I can create a new document, blank screen, no data When I open that newly created file on a iOS 17 iPad pro, it works perfect, as expected The apps were created from scratch under macOS 14.7 with the corresponding Xcode/Swift/UI version. iOS devices under iOS17 Are there any known problems with document based SwiftData-apps under iOS18, are there any changes one has to made? Thank You so much for any help!
6
0
804
Apr ’25
Reply to Need help with code signing.
It’s hard to offer a definitive answer to this because my focus is primarily technical and your relationship with your vendors is very much a business relationship. However, there are two standard ways to approach this. Both of them start with adding your developer to your team. From there: You can set their privileges such that they can do all the work on your behalf. See Developer > Support > Articles > Program Roles for info on what’s what there. You can give them limited privileges and have them send you an Xcode archive (.xcarchive), whereupon you deal with the final distribution step by loading that into Xcode. Share and Enjoy — Quinn “The Eskimo!” @ Developer Technical Support @ Apple let myEmail = eskimo + 1 + @ + apple.com
Topic: Code Signing SubTopic: General
Apr ’25
iOS 18 SwiftData ModelContext reset
Since the iOS 18 and Xcode 16, I've been getting some really strange SwiftData errors when passing @Model classes around. The error I'm seeing is the following: SwiftData/BackingData.swift:409: Fatal error: This model instance was destroyed by calling ModelContext.reset and is no longer usable. PersistentIdentifier(id: SwiftData.PersistentIdentifier.ID(url: x-coredata://34EE9059-A7B5-4484-96A0-D10786AC9FB0/TestApp/p2), implementation: SwiftData.PersistentIdentifierImplementation) The same issue also happens when I try to retrieve a model from the ModelContext using its PersistentIdentifier and try to do anything with it. I have no idea what could be causing this. I'm guessing this is just a bug in the iOS 18 Beta, since I couldn't find a single discussion about this on Google, I figured I'd mention it. if someone has a workaround or something, that would be much appreciated.
16
0
8.9k
Apr ’25
Reply to Using any SwiftData Query causes app to hang
Thank you for the answer. I'll keep the printing function in mind. As for my original issue, I later found that it was likely due to 2 embedded NavigationStack. Removing the duplicated inner stack resolved the issue. I was able to continue, but got another hang with basically the same query. I am at the point where the time I've saved with the more concise syntax of SwiftData has been completely lost to debugging issues. I will revert back to CoreData. Even if it is more code, I feel like I have better control of the behaviour and life cycle.
Mar ’25
Using any SwiftData Query causes app to hang
I want to get to a point where I can use a small view with a query for my SwiftData model like this: @Query private var currentTrainingCycle: [TrainingCycle] init(/*currentDate: Date*/) { _currentTrainingCycle = Query(filter: #Predicate { $0.numberOfDays > 0 // $0.startDate < currentDate && currentDate < $0.endDate }, sort: .startDate) } The commented code is where I want to go. In this instance, it'd be created as a lazy var in a viewModel to have it stable (and not constantly re-creating the view). Since it was not working, I thought I could check the same view with a query that does not require any dynamic input. In this case, the numberOfDays never changes after instantiation. But still, each time the app tries to create this view, the app becomes unresponsive, the CPU usage goes at 196%, memory goes way high and the device heats up quickly. Am I holding it wrong? How can I have a dynamic predicate on a View in SwiftUI with SwiftData?
2
0
243
Mar ’25
Swiftdata Thread 1: EXC_BREAKPOINT (code=1, subcode=0x1cc1698ec)
Hello, i have a route with many points for routes: @Model public class Route(){ public id: UUID = UUID() var name: String var desc: String var points: [Point] = [] } @Model public class Point(){ public id: UUID = UUID() var speed: double var route : Route } when I like to add point. route.point.append(point) I get all ways this error: Thread 1: EXC_BREAKPOINT (code=1, subcode=0x1cc1698ec) my Xcode version 15.3
1
0
601
Sep ’24
Reply to Multiple Executables in a Single Bundle Fails to Launch Others After Codesign
[quote='831680022, mmccartney, /thread/778169?answerId=831680022#831680022, /profile/mmccartney'] Each of our executables require the same entitlements: [/quote] This is potentially confusing, so let’s go to a table: Entitlement App Child ----------- --- ----- ….app-sandbox true true ….inherit - true ….cs.disable-library-validation true true ….files.user-selected.read-write true - ….network.client true - ….network.server true - In this table: App is your main application and Child is any program is spawns as a child process. - indicates that the entitlement shouldn’t be claimed at all. In general, you shouldn’t claim an entitlement with a false value, that just causes confusion. For the last three rows, you don’t need to, and mustn’t claim, the entitlement because these are part of your static sandboxed, which is what the second row is about. [quote='831680022, mmccartney, /thread/778169?answerId=831680022#831680022, /profile/mmccartney'] And if it's all going to TestFlight then I suppose it's restri
Topic: Code Signing SubTopic: General Tags:
Mar ’25
Does @Relationship(inverse:) create a memory leak?
Hi, I am creating (or trying to) my first app using SwiftData - and I have questions :-) The main question I can't get my head wrapped around is the following: Let's say I have the sample below... @Model class Person { @Relationship(inverse:Hat.owner) var hat:Hat } @Model class Hat { var owner:Person? } It looks like I am creating a strong reference cycle between the person and the hat objects? And in fact I am seeing these kinds of reference cycles when I look at the memory debugger. Many code samples I have seen so far use this type of relationship declaration... And I am wondering: Am I missing something? Admittedly I don't find many discussions about memory leaks caused by SwiftData despite the syntax being used in many examples? So what is the situation? Did Apple just miss to explain that the inverse: declaration causes memory leaks or is there some kind of magic that I should understand?
2
0
164
Mar ’25
Reply to Does @Relationship(inverse:) create a memory leak?
No, there is no reference cycle and memory leak here. By using @Model, hat and owner are converted to computed properties, and some logics are implemented there to maintain the integrity of the relationship. Those details are barely documented, but conceptually, SwiftData takes care the integrity and so you don't need to worry about that. Best, —— Ziqiao Chen  Worldwide Developer Relations.
Mar ’25
Reply to Multiple Executables in a Single Bundle Fails to Launch Others After Codesign
Quinn! Thank you for your efforts and details. Your posts on this forum have been a lifesaver for those of us new to the world of Apple development/deployment. Current Entitlements Each of our executables require the same entitlements: com.apple.security.app-sandbox com.apple.security.cs.disable-library-validation com.apple.security.files.user-selected.read-write com.apple.security.network.client com.apple.security.network.server From the research into the articles you posted, it seems like these are all safe to inherit but I could be wrong about that! And if it's all going to TestFlight then I suppose it's restricted? The lib validation is disabled because we include a plugin ecosystem through Qt. I've tried adding the com.apple.security.inherit in our entitlements but am still seeing the same issue. Here's the entitlements for the exec_b (and exec_a) > codesign -d --entitlements - exec_b Executable=/Users/foo/src/SomeApp.app/Contents/MacOS/exec_b [Dict] [Key] com.apple.security.app-sandbox [Valu
Topic: Code Signing SubTopic: General Tags:
Mar ’25
Reply to Multiple Executables in a Single Bundle Fails to Launch Others After Codesign
It should be possible to get this setup working. You mentioned TestFlight, which suggests you’re targeting the Mac App Store. If so, all your executables must be sandboxed. If you plan to spawn exec_a as a child process of exec_b then exec_b has to use sandbox inheritance. See Resolving App Sandbox Inheritance Problems. The other potential gotcha is entitlements. If exec_a uses restricted entitlements [1] then those entitlements get authorised by the provisioning profile embedded in the app bundle. If exec_b also needs restricted entitlements then things get trickier. So, does exec_b need any restricted entitlements? A restricted entitlement is one that must be authorised by a profile, as explained in TN3125 Inside Code Signing: Provisioning Profiles. Finally, I have a bunch of hints and tips on this topic in Resolving Trusted Execution Problems. Share and Enjoy — Quinn “The Eskimo!” @ Developer Technical Support @ Apple let myEmail = eskimo + 1 + @ + apple.com [1] Which it’ll need for a Tes
Topic: Code Signing SubTopic: General Tags:
Mar ’25
Reply to Clarification on Family Controls Entitlement Coverage for App Extensions
Can you try only adding the capabilities and permissions on the main app when you archive? The extensions should inherit these, rather than need to also have a declaration.
Replies
Boosts
Views
Activity
Apr ’25
Reply to Multiple Executables in a Single Bundle Fails to Launch Others After Codesign
Getting back to this! Thanks again or the detailed response. The ugly truth is we need exec_b to be run from exec_a and by thirdparty tools that might need to call up it's UI. Think of exec_a as a sort of launcher program that orchestrates exec_b instances it's called up but so too do other parts of our pipeline, potentially. [quote='831858022, DTS Engineer, /thread/778169?answerId=831858022#831858022'] Add com.apple.application-identifier and com.apple.developer.team-identifier to your App. [/quote] Where should this be put? In the entitlements.plist we use while signing App? If we're to test the .inherit entitlement to just get exec_a launching exec_b, you're describing something like: # codesign other binaries... (macdeployqt does much of this work) # Sign child exec codesign ... --entitlements=./entitle_child.plist .../exec_b # Then sign the App (including the com.apple.application... tags) codesign ... --entitlements=./entitle_app.plist .../App.app Apologies if I'm missing the mark here. App val
Topic: Code Signing SubTopic: General Tags:
Replies
Boosts
Views
Activity
Apr ’25
Reply to CloudKit not storing or updating public data in real time.
interferon, thanks for responding. Doing another google search for answers I learned that SwiftData and CloudKit only do private databases. So, I need to wait for the next best SwiftData update in order to have a public database. I can wait. So SwiftData and Cloudkit are not using public databases at this time.
Topic: Design SubTopic: General Tags:
Replies
Boosts
Views
Activity
Apr ’25
SwiftData document based on iOS18 shows blank screen
I have some apps using SwiftData document based. They work as expected under iOS17, but not under iOS18: install the app on a iPad 11 pro (first gen) from my MacBook open the app and open an existing fils (perfect under iOS17) it shows a blank, white screen, no data I can create a new document, blank screen, no data When I open that newly created file on a iOS 17 iPad pro, it works perfect, as expected The apps were created from scratch under macOS 14.7 with the corresponding Xcode/Swift/UI version. iOS devices under iOS17 Are there any known problems with document based SwiftData-apps under iOS18, are there any changes one has to made? Thank You so much for any help!
Replies
6
Boosts
0
Views
804
Activity
Apr ’25
Reply to Need help with code signing.
It’s hard to offer a definitive answer to this because my focus is primarily technical and your relationship with your vendors is very much a business relationship. However, there are two standard ways to approach this. Both of them start with adding your developer to your team. From there: You can set their privileges such that they can do all the work on your behalf. See Developer > Support > Articles > Program Roles for info on what’s what there. You can give them limited privileges and have them send you an Xcode archive (.xcarchive), whereupon you deal with the final distribution step by loading that into Xcode. Share and Enjoy — Quinn “The Eskimo!” @ Developer Technical Support @ Apple let myEmail = eskimo + 1 + @ + apple.com
Topic: Code Signing SubTopic: General
Replies
Boosts
Views
Activity
Apr ’25
iOS 18 SwiftData ModelContext reset
Since the iOS 18 and Xcode 16, I've been getting some really strange SwiftData errors when passing @Model classes around. The error I'm seeing is the following: SwiftData/BackingData.swift:409: Fatal error: This model instance was destroyed by calling ModelContext.reset and is no longer usable. PersistentIdentifier(id: SwiftData.PersistentIdentifier.ID(url: x-coredata://34EE9059-A7B5-4484-96A0-D10786AC9FB0/TestApp/p2), implementation: SwiftData.PersistentIdentifierImplementation) The same issue also happens when I try to retrieve a model from the ModelContext using its PersistentIdentifier and try to do anything with it. I have no idea what could be causing this. I'm guessing this is just a bug in the iOS 18 Beta, since I couldn't find a single discussion about this on Google, I figured I'd mention it. if someone has a workaround or something, that would be much appreciated.
Replies
16
Boosts
0
Views
8.9k
Activity
Apr ’25
Reply to Using any SwiftData Query causes app to hang
Thank you for the answer. I'll keep the printing function in mind. As for my original issue, I later found that it was likely due to 2 embedded NavigationStack. Removing the duplicated inner stack resolved the issue. I was able to continue, but got another hang with basically the same query. I am at the point where the time I've saved with the more concise syntax of SwiftData has been completely lost to debugging issues. I will revert back to CoreData. Even if it is more code, I feel like I have better control of the behaviour and life cycle.
Replies
Boosts
Views
Activity
Mar ’25
Using any SwiftData Query causes app to hang
I want to get to a point where I can use a small view with a query for my SwiftData model like this: @Query private var currentTrainingCycle: [TrainingCycle] init(/*currentDate: Date*/) { _currentTrainingCycle = Query(filter: #Predicate { $0.numberOfDays > 0 // $0.startDate < currentDate && currentDate < $0.endDate }, sort: .startDate) } The commented code is where I want to go. In this instance, it'd be created as a lazy var in a viewModel to have it stable (and not constantly re-creating the view). Since it was not working, I thought I could check the same view with a query that does not require any dynamic input. In this case, the numberOfDays never changes after instantiation. But still, each time the app tries to create this view, the app becomes unresponsive, the CPU usage goes at 196%, memory goes way high and the device heats up quickly. Am I holding it wrong? How can I have a dynamic predicate on a View in SwiftUI with SwiftData?
Replies
2
Boosts
0
Views
243
Activity
Mar ’25
Reply to Swiftdata Thread 1: EXC_BREAKPOINT (code=1, subcode=0x1cc1698ec)
Hi there, I encountered the same error when defining mutual @Relationship references (one-to-many or many-to-many relationships) between two models. Have you found a solution? thx
Replies
Boosts
Views
Activity
Mar ’25
Swiftdata Thread 1: EXC_BREAKPOINT (code=1, subcode=0x1cc1698ec)
Hello, i have a route with many points for routes: @Model public class Route(){ public id: UUID = UUID() var name: String var desc: String var points: [Point] = [] } @Model public class Point(){ public id: UUID = UUID() var speed: double var route : Route } when I like to add point. route.point.append(point) I get all ways this error: Thread 1: EXC_BREAKPOINT (code=1, subcode=0x1cc1698ec) my Xcode version 15.3
Replies
1
Boosts
0
Views
601
Activity
Sep ’24
Reply to Multiple Executables in a Single Bundle Fails to Launch Others After Codesign
[quote='831680022, mmccartney, /thread/778169?answerId=831680022#831680022, /profile/mmccartney'] Each of our executables require the same entitlements: [/quote] This is potentially confusing, so let’s go to a table: Entitlement App Child ----------- --- ----- ….app-sandbox true true ….inherit - true ….cs.disable-library-validation true true ….files.user-selected.read-write true - ….network.client true - ….network.server true - In this table: App is your main application and Child is any program is spawns as a child process. - indicates that the entitlement shouldn’t be claimed at all. In general, you shouldn’t claim an entitlement with a false value, that just causes confusion. For the last three rows, you don’t need to, and mustn’t claim, the entitlement because these are part of your static sandboxed, which is what the second row is about. [quote='831680022, mmccartney, /thread/778169?answerId=831680022#831680022, /profile/mmccartney'] And if it's all going to TestFlight then I suppose it's restri
Topic: Code Signing SubTopic: General Tags:
Replies
Boosts
Views
Activity
Mar ’25
Does @Relationship(inverse:) create a memory leak?
Hi, I am creating (or trying to) my first app using SwiftData - and I have questions :-) The main question I can't get my head wrapped around is the following: Let's say I have the sample below... @Model class Person { @Relationship(inverse:Hat.owner) var hat:Hat } @Model class Hat { var owner:Person? } It looks like I am creating a strong reference cycle between the person and the hat objects? And in fact I am seeing these kinds of reference cycles when I look at the memory debugger. Many code samples I have seen so far use this type of relationship declaration... And I am wondering: Am I missing something? Admittedly I don't find many discussions about memory leaks caused by SwiftData despite the syntax being used in many examples? So what is the situation? Did Apple just miss to explain that the inverse: declaration causes memory leaks or is there some kind of magic that I should understand?
Replies
2
Boosts
0
Views
164
Activity
Mar ’25
Reply to Does @Relationship(inverse:) create a memory leak?
No, there is no reference cycle and memory leak here. By using @Model, hat and owner are converted to computed properties, and some logics are implemented there to maintain the integrity of the relationship. Those details are barely documented, but conceptually, SwiftData takes care the integrity and so you don't need to worry about that. Best, —— Ziqiao Chen  Worldwide Developer Relations.
Replies
Boosts
Views
Activity
Mar ’25
Reply to Multiple Executables in a Single Bundle Fails to Launch Others After Codesign
Quinn! Thank you for your efforts and details. Your posts on this forum have been a lifesaver for those of us new to the world of Apple development/deployment. Current Entitlements Each of our executables require the same entitlements: com.apple.security.app-sandbox com.apple.security.cs.disable-library-validation com.apple.security.files.user-selected.read-write com.apple.security.network.client com.apple.security.network.server From the research into the articles you posted, it seems like these are all safe to inherit but I could be wrong about that! And if it's all going to TestFlight then I suppose it's restricted? The lib validation is disabled because we include a plugin ecosystem through Qt. I've tried adding the com.apple.security.inherit in our entitlements but am still seeing the same issue. Here's the entitlements for the exec_b (and exec_a) > codesign -d --entitlements - exec_b Executable=/Users/foo/src/SomeApp.app/Contents/MacOS/exec_b [Dict] [Key] com.apple.security.app-sandbox [Valu
Topic: Code Signing SubTopic: General Tags:
Replies
Boosts
Views
Activity
Mar ’25
Reply to Multiple Executables in a Single Bundle Fails to Launch Others After Codesign
It should be possible to get this setup working. You mentioned TestFlight, which suggests you’re targeting the Mac App Store. If so, all your executables must be sandboxed. If you plan to spawn exec_a as a child process of exec_b then exec_b has to use sandbox inheritance. See Resolving App Sandbox Inheritance Problems. The other potential gotcha is entitlements. If exec_a uses restricted entitlements [1] then those entitlements get authorised by the provisioning profile embedded in the app bundle. If exec_b also needs restricted entitlements then things get trickier. So, does exec_b need any restricted entitlements? A restricted entitlement is one that must be authorised by a profile, as explained in TN3125 Inside Code Signing: Provisioning Profiles. Finally, I have a bunch of hints and tips on this topic in Resolving Trusted Execution Problems. Share and Enjoy — Quinn “The Eskimo!” @ Developer Technical Support @ Apple let myEmail = eskimo + 1 + @ + apple.com [1] Which it’ll need for a Tes
Topic: Code Signing SubTopic: General Tags:
Replies
Boosts
Views
Activity
Mar ’25