Post

Replies

Boosts

Views

Activity

Reply to Swift compiler crashes with simple SwiftData model
I was original poster for this thread. After finding the problem still exists in beta 7 and discovered the issue is caused by defining a SwiftData model in a Package. The compilation error occurs when the model package is imported into a different package, including unit test. @qmay provided this confirmation, with an awkward workaround. Check this GitHub issue — qmay 2 days ago I submitted a Feedback FB13034576 including sample to reproduce. I also confirmed that copying the exact swift file directly into an app project will compile and run without error. For now, I've been forced to abandon package modularity and copy may SwiftData code directly into my app project.
Aug ’23
Reply to Swift compiler crashes with simple SwiftData model
I removed didSet, private set, and made every attribute optional. Cleaned the build folder, exited and restarted Xcode. And the compile still crashes. This is a very simple example, but within a Swift Package with a single unit test (where the compile crashes). I'll try embedding this package into a simple app. This is all that's left in the model: @Model public final class Note { public var id: UUID? public var createdDate: Date? public var updatedDate: Date? public var title: String? public var content: String? public init(title: String? = nil, content: String) { self.id = UUID() self.createdDate = Date() self.updatedDate = Date() self.title = title self.content = content } } `
Aug ’23
Reply to Swift compiler crashes with simple SwiftData model
Good idea, but I removed Identifiable and the project still crashes. What's especially strange is that this example was part of a larger model that started crashing with beta 6. Other entities compile and run successfully. I isolated this example into a new Package with a simple unit test. The compile stack track includes this: While finishing conformance for protocol conformance to 'PersistentModel' (in module 'SwiftData') for type 'Note' *** DESERIALIZATION FAILURE *** *** If any module named here was modified in the SDK, please delete the *** *** new swiftmodule files from the SDK and keep only swiftinterfaces. *** module 'TestNote', builder version '5.9(5.9)/Apple Swift version 5.9 (swiftlang-5.9.0.128.2 clang-1500.0.40.1)', built from source, non-resilient, loaded from '/Users/dcarlson/Library/Developer/Xcode/DerivedData/TestNote-bfabsndeemmksbfnkuqgjhrdwipm/Build/Products/Debug-iphonesimulator/TestNote.swiftmodule/arm64-apple-ios-simulator.swiftmodule' serialized conformances do not match requirement signature
Aug ’23
Reply to Swift compiler crashes with simple SwiftData model
iOS beta 6 was released today and the notes indicate a long list of SwiftData issues fixed. But no update to Xcode beta 7, so I don't see any way to test the iOS SwiftData improvements in the simulator or debug on a device until Xcode is updated? I can't edit my code snippet above, but there was a @Model macro and I created a complete Package project to reproduce this compile crash issue and submitted to Apple. The model compiles fine in Xcode beta 5 and the unit test runs successfully. Looks like I may need to wait another week for Xcode beta 7?
Aug ’23