Post

Replies

Boosts

Views

Activity

Reply to iOS 17b6: Simultaneous accesses to ..., but modification requires exclusive access crash using Observation and SwiftUI
Given below is my understanding (I could be wrong). It looks like a concurrency issue. @Observable does ensure properties are accessed on the main thread, so it is thread safe. However by accessing a static property containing the AppModel, the AppModel might not longer guarantee thread safety. Based on the crash it seems like it is caused by simultaneous access (possibly from different threads). Debug Turn on Swift Strict Concurrency to complete to spot any warnings thrown by the compiler. Solution If you want to pass around the model use @Environment across views and access them across views If you have different models and need to talk to each other find ways to isolate and protect access using actors.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Aug ’23
Reply to SwiftData crashes the app on iOS Beta 6
I have created a default SwiftData app by selecting the storage as SwiftData. The app runs fine on iOS simulator, there is no crash. I am using Xcode 15 Beta 6. Do you have any framework that you have added to your project? Can you clear DerivedData and create a new project and test using Xcode Beta 6?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Aug ’23
Reply to iOS 17b6: Simultaneous accesses to ..., but modification requires exclusive access crash using Observation and SwiftUI
Just curious: Why do you need a shared static property on AppModel? Since Folder conforms to identifiable in SidebarView could you just use ForEach(folders) { folder in? Note: I don't have an iOS 17 device so couldn't test it on real device. Could you make the above 2 changes mentioned and test it? Just trying to understand what causes the crash?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Aug ’23
Reply to SwiftData. Predicate. Issue accessing self (Entity) inside a Predicate
Based on my experience, using self inside #predicate is not allowed. Do you have unique identifier field for Item? If so store that then use unique identifier in a variable and then use id inside your #predicate. Assume name is the unique identifier then use the following code example: let id = self.name let predicate = #predicate { $0.item.name == id } ....
Aug ’23
Reply to ShareLink with custom Transferable struct using FileRepresentation not working as expected
Yeah I have trouble with FileRepresentation and Share, however I am able to drag and drop to the finder. Just check if you are able to drag and drop the finder (on macOS Sonoma). In my case it was a plain text file so I was using the contentType as utf8PlainText. When I had used .text it didn't work. Might be worth filing a feedback and posting the feedback ID.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Aug ’23