Post

Replies

Boosts

Views

Activity

Reply to Crash by SwiftData MigarionPlan
I'm facing the same issue as you. When testing on iOS 18 (I don't have a lower version device) using Xcode, everything works fine. However, the app crashes when distributed through TestFlight, and strangely, the second time I try to run it, the crash is gone. The error message indicates a missing critical piece of data. In a moment of desperation, I wrote some seemingly silly code, but surprisingly, it worked, and the TestFlight crash no longer occurs. before: @MainActor class MyModelContainer { @AppStorage(StorageKeys.iCloudSync) public var iCloudSync: Bool = true static let shared = MyModelContainer() let container: ModelContainer private init() { let schema = Schema(versionedSchema: SchemaLatest.self) container = try! ModelContainer(for: schema, migrationPlan: MeMigrationPlan.self, configurations: [ModelConfiguration(isStoredInMemoryOnly: false, cloudKitDatabase: Preferences.shared.iCloudSync ? .automatic : .none)]) } } after: @MainActor class MyModelContainer { @AppStorage(StorageKeys.iCloudSync) public var iCloudSync: Bool = true static let shared = MyModelContainer() let container: ModelContainer private init() { let schema = Schema(versionedSchema: SchemaLatest.self) do { container = try ModelContainer(for: schema, migrationPlan: MeMigrationPlan.self, configurations: [ModelConfiguration(isStoredInMemoryOnly: false, cloudKitDatabase: Preferences.shared.iCloudSync ? .automatic : .none)]) } catch { container = try! ModelContainer(for: schema, migrationPlan: MeMigrationPlan.self, configurations: [ModelConfiguration(isStoredInMemoryOnly: false, cloudKitDatabase: Preferences.shared.iCloudSync ? .automatic : .none)]) } } }
Jul ’24
Reply to TipKit: How to support `concurrency-safe`
@MainActor struct SomeTip: Tip { @Parameter static var haveSome: Bool = false static let eventOneHappened = Event(id: "eventOneHappened") nonisolated var title: Text { MainActor.assumeIsolated { Text("***") } } nonisolated var image: Image? { MainActor.assumeIsolated { Image(systemName: "heart") } } nonisolated var options: [TipOption] { MainActor.assumeIsolated { [Tip.MaxDisplayCount(1)] } } nonisolated var rules: [Rule] { MainActor.assumeIsolated { [ #Rule(Self.$haveSome) { $0 == true }, #Rule(Self.eventOneHappened) { $0.donations.count >= 1 } ] } } } I wrote it like this at the beginning. Although there is no warning now, it looks strange. However, my rules are pretty simple, all it takes is control through Event.
May ’24