Skip to content

SyncEngine init crashes in Swift runtime while de-duping synchronized tables #474

@iSapozhnik

Description

@iSapozhnik

Description

Our macOS app crashes at runtime while initializing SQLiteData.SyncEngine.

The project builds successfully, but the app crashes during SyncEngine.init, before startup completes. Cleaning DerivedData and doing a clean build does not change the behavior. I would greatly appreciate any suggestions!

The crash appears to occur in SyncEngine.swift while de-duping synchronized tables:

let allTables = OrderedSet((tables + privateTables).map(HashableSynchronizedTable.init))
  .map(\.type)

The app does not reach the log immediately after SyncEngine initialization.

Possibly relevant Tuist package product typing:

let packageSettings = PackageSettings(
  productTypes: [
    "SQLiteData": .staticFramework,
  ]
)

Dependency:

.package(url: "https://github.com/pointfreeco/sqlite-data", from: "1.6.3")

Checklist

  • I have determined whether this bug is also reproducible in a vanilla SwiftUI project.
  • I have determined whether this bug is also reproducible in a vanilla GRDB project.
  • If possible, I've reproduced the issue using the main branch of this package.
  • This issue hasn't been addressed in an existing GitHub issue or discussion.

Expected behavior

SyncEngine initializes successfully for the configured synchronized tables, and app startup continues.

Actual behavior

The macOS app crashes during SyncEngine.init.

Xcode reports:

Thread 1: EXC_BAD_ACCESS (code=1, address=0x0)

Tables passed to SyncEngine:

try SyncEngine(
  for: database,
  tables: RewriteMode.self, RewriteModeSeedDeletion.self, Snippet.self,
  privateTables: RewriteHistoryEntry.self,
  containerIdentifier: containerIdentifier,
  startImmediately: startImmediately,
  logger: logger
)

Table shape:

  • RewriteMode: @Table("rewriteModes"), primary key String
  • RewriteModeSeedDeletion: @Table("rewriteModeSeedDeletions"), primary key String
  • Snippet: @Table("snippets"), primary key String
  • RewriteHistoryEntry: @Table, primary key UUID

Stack:

Thread 0 Crashed:
swift::TargetMetadata<swift::InProcess>::getTypeContextDescriptor() const
swift::SubstGenericParametersFromMetadata::SubstGenericParametersFromMetadata(...)
swift_getAssociatedTypeWitnessSlowImpl(...)
Collection.map<A, B>(_:)
SyncEngine.init(container:defaultZone:defaultSyncEngines:userDatabase:logger:delegate:tables:privateTables:)
SyncEngine.__allocating_init(container:defaultZone:defaultSyncEngines:userDatabase:logger:delegate:tables:privateTables:)
SyncEngine.__allocating_init<each A, B>(for:tables:privateTables:containerIdentifier:defaultZone:startImmediately:delegate:logger:)
CloudKitSyncService.init(database:containerIdentifier:startImmediately:)
PersistenceBootstrap.makePersistenceClients()
AppServices.makeLive()
ReforgeApp.init()
static App.main()

Reproducing project

I do not yet have a standalone reproducing project. The current reproduction is in a Tuist-generated macOS app project using the SyncEngine initialization shown above.

SQLiteData version information

1.6.3

Sharing version information

2.8.0

GRDB version information

7.10.0

Destination operating system

macOS 26.5.1

Xcode version information

Xcode 26.4.1

Swift Compiler version information

swift-driver version: 1.148.6 Apple Swift version 6.3.1 (swiftlang-6.3.1.1.2 clang-2100.0.123.102)
Target: arm64-apple-macosx26.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions