You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

启用CloudKit时SwiftData自定义迁移崩溃问题求助

问题:启用CloudKit时Core Data自定义迁移失败,存储版本无法更新

原上线应用仅有一个CDShift实体:

@Model
final class CDShift {
    var identifier: UUID = UUID()
    var date: Date = Date()
    ...
}

需对应用做以下更新:

  • 添加新实体DayPlan
  • 建立DayPlan与CDShift的关联

已执行的迁移步骤:

  • 用SchemaV1封装原CDShift实体,版本号设为1.0.0
  • 创建SchemaV2,添加DayPlan实体及两者关联,版本号设为2.0.0
  • 定义MigrationPlan实现V1到V2的自定义迁移,在didMigrate方法中为所有原有CDShift创建对应的DayPlan

出现的问题:

  • 创建ModelContainer时触发崩溃,错误信息如下:
Unable to find a configuration named 'default' in the specified managed object model.
  • 存储版本始终停留在1,无法更新至2
  • 尝试轻量迁移无崩溃,但版本仍未更新
  • 仅在启用CloudKit时出现此问题

内容的提问来源于stack exchange,提问作者Andrea Mario Lufino

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.21 08:52:33