Regenerate Swift bindings and commit them on every release - #26
Conversation
The SPM package compiles `swift/Sources/CooklangSync` straight out of the repo, but the release workflow only ever generated the bindings into the release zip and committed `Package.swift`. The checked-in bindings had not been regenerated since v0.4.10, so every consumer since v0.4.11 has been compiling an enum that no longer matches the xcframework it links against. `SyncError` is a `flat_error`, so the variant is carried across FFI as a positional index. The stale file still declares `ReqwestWirhMiddlewareError` at index 9 — a variant Rust dropped in 04a0560 — which shifts everything after it by one: Rust ChannelSendError (9) -> Swift ReqwestWirhMiddlewareError Rust ConnectionInitError (10) -> Swift ChannelSendError Rust Unauthorized (11) -> Swift ConnectionInitError Rust PaymentRequired (12) -> Swift Unauthorized On 0.6.0 that last row is the damaging one: the 402 added in f0a517f surfaces to iOS as `Unauthorized`, i.e. "your session expired", which is exactly the wrong route for a product gate. Two changes: - Replace the stale bindings with the ones the v0.6.0 release actually generated (byte-identical to `cooklang-sync-ios.zip`). The only difference from the checked-in file is the `SyncError` enum; renamed to `CooklangSync.swift` to match the generator's output filename so CI can overwrite it in place. - Have `prepare-release` pull the generated bindings from `build-ios` and commit them alongside `Package.swift`, so the tag can never again point at bindings that disagree with its xcframework.
ReviewNice root-cause diagnosis — tracing the Bug:
|
The SPM package compiles
swift/Sources/CooklangSyncstraight out of therepo, but the release workflow only ever generated the bindings into the
release zip and committed
Package.swift. The checked-in bindings had notbeen regenerated since v0.4.10, so every consumer since v0.4.11 has been
compiling an enum that no longer matches the xcframework it links against.
SyncErroris aflat_error, so the variant is carried across FFI as apositional index. The stale file still declares
ReqwestWirhMiddlewareErrorat index 9 — a variant Rust dropped in 04a0560 — which shifts everything
after it by one:
On 0.6.0 that last row is the damaging one: the 402 added in f0a517f
surfaces to iOS as
Unauthorized, i.e. "your session expired", which isexactly the wrong route for a product gate.
Two changes:
generated (byte-identical to
cooklang-sync-ios.zip). The onlydifference from the checked-in file is the
SyncErrorenum; renamed toCooklangSync.swiftto match the generator's output filename so CI canoverwrite it in place.
prepare-releasepull the generated bindings frombuild-iosandcommit them alongside
Package.swift, so the tag can never again pointat bindings that disagree with its xcframework.