Post

Replies

Boosts

Views

Activity

modelContext.fetchIdentifiers(descriptor) Errors when Using a SortDescriptor
modelContext.fetchIdentifiers(descriptor) errors when using a SortDescriptor to sort by a variable and returns no models. The fetch works fine without a SortDescriptor, thus FetchDescriptor<MyModel>() works fine, but FetchDescriptor<MyModel>(sortBy: [.init(\.title)]) or FetchDescriptor<MyModel>(sortBy: [SortDescriptor(\.title)]) errors with console message The operation couldn’t be completed. (SwiftData.SwiftDataError error 1.) I am using Xcode Version 16.0 beta 6 (16A5230g).
1
0
396
Aug ’24
error: the replacement path doesn't exist:
I'm using SwiftData with an @Model and am also using an @ModelActor. I've fixed all concurrency issues and have migrated to Swift 6. I am getting a console error that I do not understand how to clear. I get this error in Swift 6 and Swift 5. I do not experience any issue with the app. It seems to be working well. But I want to try to get all issues taken care of. I am using the latest Xcode beta. error: the replacement path doesn't exist: "/var/folders/1q/6jw9d6mn0gx1znh1n19z2v9r0000gp/T/swift-generated-sources/@_swiftmacro_17MyAppName14MyModelC4type18_PersistedPr> opertyfMa.swift"
22
9
5k
Aug ’24
Swift 6, SwiftData modelContext.save() Crashes, Does not AutoSave
I took one of my apps and have gone through the process of making it compatible with Swift 6. I started with Swift 5 and Complete Concurrency Checking and eliminated every warning. I flipped the switch to Swift 6 and I have no compile errors and no warnings. I also created a ModelActor and created async functions to fetch, delete, get an object's persistentID and save model objects. My SwiftData model has a notes property and the user can update or add onto the notes and resave the model object. The app crashes when I save the changes using an explicit save operation. However, the next time the app is launched, the changes did propagate. If I do not use the explicit save operation, the system does not auto-save and does not crash. When I switched back to Swift 5 and tried it out, I was able to save without a crash. I did need to use an explicit save operation though. However, I am now getting 3 warnings like the following. Type 'ReferenceWritableKeyPath<MyModel, Optional>' does not conform to the 'Sendable' protocol; this is an error in the Swift 6 language mode The line of code that produced that warning is `let fetchDescriptor = FetchDescriptor(sortBy: [SortDescriptor(\MyModel.title)]) However, when I flip the switch back to Swift 6, the three warnings go away and I have zero warnings under Swift 6.
5
0
750
Aug ’24
Main actor-isolated instance method 'locationManagerDidChangeAuthorization' cannot be used to satisfy nonisolated protocol requirement
I'm going through the migration to Swift 6 and I am running up with a few things. I have two view controllers which conform to the CLLocationManagerDelegate protocol. Both methods of the delegate have the same issue in my code. Below is an example of the warning received. Main actor-isolated instance method 'locationManagerDidChangeAuthorization' cannot be used to satisfy nonisolated protocol requirement; this is an error in the Swift 6 language mode
4
0
2.6k
Jul ’24
Text Above List w/ VStack Appears as View's Title
I am curious about the fact that the Text above the VStack is shown as a title to the view. I didn't know one could place Text above a VStack without another VStack. Here's the partial code showing the situation. @State private var results = [Result]() var body: some View { Text("Songs of Al Di Meola on iTunes") .font(.title3) .fontWeight(.bold) List(results, id: \.trackId) { item in VStack(alignment: .leading) { Text(item.trackName) .font(.headline) Text(item.collectionName) } } .task { await loadData() } } See picture for details.
0
0
313
Jul ’24
visionOS Build Issues
I've been working on a visionOS platform for my existing app. I added the visionOS platform in App Store Connect. In Xcode 15.2, I set the destination to 'Any visionOS Device (Designed for iPad, arm64)'. The App Store Connect visionOS platform does not see the build. It does show up as an iOS build on Test Flight. I don't see anyway to designate the build as a build that the visionOS destination sees. Also, the upload failed when I tried to set the version for the app as 1.0. It went through when I put the version as a number higher than my iOS app version.
2
0
801
Jan ’24
About Adding a visionOS Platform and Uploading a visionOS Binary
I have modified two of my apps to run on visionOS and I see that in App Store Connect, one add a visionOS Platform. My question is, why would I want to do this if I can't upload a visionOS binary? Would it be to work on the metadata? Also, I would like to have my visionOS binary evaluated. Is there any way to do this at this time? It appears that only iOS or iPadOS apps are being evaluated.
1
0
614
Nov ’23