xykong36 / SplitCircle

Big Money Split App
0 stars 0 forks source link

TestFlight 旧版本更新直接Crash了 #46

Closed xykong36 closed 4 months ago

xykong36 commented 5 months ago

https://appstoreconnect.apple.com/apps/6499389121/testflight/crashes/AKZ93xXAk5B0qBSbBkxKuu0?appPlatform=IOS&preReleaseVersionId=6ee0ee53-ecb2-41c0-8d98-652eb25398a7&sort=-timestamp

应该是SwiftData Model 更新导致的

xykong36 commented 4 months ago

SwiftData Migration 的问题 先选择暴力更新指定database store 的位置

let databasePath = URL.documentsDirectory.appending(path: "databasev2.store")

    init() {
        let configuration = ModelConfiguration(url: databasePath)
        do {
            customModelContainer = try ModelContainer(
                for: MemberGroup.self, User.self, ExpenseTransaction.self, Expense.self,
                configurations: configuration
            )
        } catch {
            fatalError("Failed to initialize model container.")
        }
    }