Repository navigation
Version Coexistence
This page explains how the Swift Bindings NuGet packages relate across versions: why a generated
binding pins a bounded range on SwiftBindings.Runtime, what the practical consequences are for
your projects, and why two bindings built a minor apart cannot be installed side by side.
If you just want the upgrade steps, see Upgrading. This page is the "why" behind the
version ranges you'll see in a generated .csproj.
| Package | Role | Range it declares on SwiftBindings.Runtime
|
|---|---|---|
SwiftBindings.Runtime |
The runtime itself (native + managed) | — |
SwiftBindings.Sdk + every generated binding |
Consume the runtime directly |
bounded [X.Y.Z, X.(Y+1).0)
|
SwiftBindings.Apple supplement |
Always brokered through the SDK |
floor-only [A.B.C,)
|
A generated binding and the SDK reference the Runtime directly, so they carry the bounded range.
The Apple supplement is only ever pulled in transitively through the SDK — whose own bounded range
supplies the ceiling — so the supplement only needs to declare a floor. That lets one shipped
supplement package ride forward across Runtime/SDK minor bumps without a no-op repack, which is why
its version (e.g. 26.2.8, tracking the Apple SDK train) won't match the SDK/Runtime/Templates
semver.
NuGet treats a plain Version="X.Y.Z" as a minimum — it will happily resolve a future
X.(Y+1).0 if one is available locally. The compatibility promise behind the bounded range is:
- Patch is ABI-additive only — no struct-layout, P/Invoke-signature, calling-convention, or public-API removal or change.
- A minor is allowed to break ABI.
So the bounded range [X.Y.Z, X.(Y+1).0):
- floats forward across Runtime patch releases — an ABI-compatible bug fix reaches every consumer without anyone republishing a binding…
- …but slams shut at the next minor, so a future ABI break cannot silently load under an older binding and crash at a P/Invoke.
A new Runtime patch (X.Y.Z → X.Y.(Z+1)) is picked up automatically by every binding in the
bounded range. You don't need to rebuild or republish your bindings for an ABI-compatible fix.
If one project references binding A built against Runtime X.Y.* and binding B built against
Runtime X.(Y+1).*, NuGet restore fails with NU1107 (version conflict). This is intentional:
a hard restore error is strictly better than silently loading a possibly ABI-incompatible runtime and
crashing later. A Runtime minor is where ABI breaks are allowed to land, so NuGet refuses to mix
the two rather than gamble that this particular minor happened not to break the dispatch contract.
Mitigation is process, not configuration: rebuild all bindings in a solution against the same Runtime minor. Because Runtime-minor bumps are kept rare (ABI breaks are batched into them), this boundary is hit infrequently in practice. If you maintain several binding packages, release them as a set against a single Runtime minor.
The bounded-minor range is enforced by NuGet at restore time. As defense in depth, the Runtime
also performs a load-time check. Each generated binding records an integer epoch
(major × 1000 + minor, so 0.19.0 is 19 and 11.0.0 is 11000) and at module initialization
the Runtime verifies that epoch falls in [MinimumSupportedGeneratedVersion, Version]. From 11.0.0
the floor is 11000, so Runtime 11.0 refuses a binding generated by SDK 0.15 through 0.20.
Through 0.20 the floor was 16. Bindings from 0.14 and earlier predate this check, and only the
NuGet range keeps them away from Runtime 11.0. An unversioned (0.0.0-dev) build records epoch 0, which the load-time check always accepts. In normal use you
never see this gate — the bounded PackageReference range keeps the pair in sync — but if an
out-of-window binding ever reaches the loader (NativeAOT slice selection, a ProjectReference
diamond, a hand-edited reference), it fails fast rather than crashing deep in a native call.
Starting in 11.0.0, the compatibility check also runs at build time so an out-of-window binding
fails the build instead of failing at app launch. Every build that references
SwiftBindings.Runtime (apps and class libraries, on every .NET runtime engine) compares each
referenced generated binding's epoch against the supported window of the resolved
SwiftBindings.Runtime. Any binding the runtime will not load stops the build with
SWIFTBIND144, naming the assembly, its package, its epoch, and the supported window.
Bindings generated before the epoch existed are refused as well. Binding packages that record
epoch 0 (from an unversioned build) are also refused, including every SwiftBindings.Apple package
published before 11.0.0. If the error names SwiftBindings.Apple, remove your explicit reference
(the SDK and the packages that need it bring in the matching version), or update the package to the
version released with 11.0.0. A project reference that records epoch 0 is still accepted. Referenced libraries that only use
the runtime (rather than being generated bindings) are not checked, and neither is a 0.0.0-dev
runtime. There is no opt-out. Rebuild the binding with the same SwiftBindings.Sdk minor version as
the runtime, or reference a binding package built with that version.
NuGet can additionally diff each pack against a previously published baseline package
(PackageValidationBaselineVersion). This is deliberately not enabled before 1.0, because
setting a baseline forces NuGet to download the baseline package at pack time, which breaks offline
and dry-run packing — and the bounded-minor window already delivers the same safety (an ABI break
lands in a minor, and the bounded range makes that minor uninstallable alongside older bindings).
This is expected to be revisited at 1.0: once a 1.x line pledges no ABI break within a major, a baseline check becomes the right tool to prove that pledge, and the minor window may widen.
- Platform Compatibility — the other version axis: TFM band, Apple SDK, and minimum-OS requirements for authors, consumers, and devices.
- Upgrading — step-by-step version-bump instructions.
- Publishing — packing and distributing your own bindings.
- NativeAOT Deployment — runtime embedding on device.
Swift Bindings for .NET
Get Started
Guides
- Upgrading
- Apple Frameworks
- SwiftUI Interop
- Customization
- Multi-Framework Libraries
- Publishing
- NativeAOT Deployment
Reference
Links