← Back to the journal

May 11, 2025 · ORIGINAL ARCHIVE

Swift iOS Log

Original author: Matt · Preserved from the original blog.

Swiftdata Bug: Duplicate version checksums detected

iOS 18.4 simulator and device crashing with the following error:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Duplicate version checksums detected.'
*** First throw call stack:

This occurred when running swiftdata schema migrations.

Solution

Namespace all data models in versioned schemas.
Avoid sharing models across different versions of the schema, even if they are identical.

example:

// Version 1
enum ModelSchemaV1: VersionedSchema {
  static var versionIdentifier: Schema.Version {
    Schema.Version(1, 0, 0)
  }
}

extension ModelSchemaV1 {
  @Model
  class DataModel: Decodable {
    @Attribute(.unique) var id: String
  }
}

// Version 2
enum ModelSchemaV2: VersionedSchema {
  static var versionIdentifier: Schema.Version {
    Schema.Version(2, 0, 0)
  }
}

extension ModelSchemaV2 {
  @Model
  class DataModel: Decodable {
    @Attribute(.unique) var id: String
  }
}
About this archive

This article preserves the original writing and code. Older examples may use earlier library versions.

Original path: /2025/05/11/swift-ios-bugs-log.html