An SDK update can turn a once-stable integration into a set of compiler errors. Around the iOS 9 release, changes to Core Bluetooth's peripheral API affected projects that still expected the older connection and UUID properties.
Rather than spread version checks across every call site, a small Swift extension offers one place to translate the newer API into names that make sense to existing application code. The connection state can be read from the peripheral's current state, and its identifier can stand in for the former UUID value.
Put the compatibility mapping in one place
This Swift 2-era sketch shows the shape of that adapter. It is illustrative: verify the exact imported names and Objective-C visibility against the SDK and Swift compiler used by the project.
extension CBPeripheral {
var legacyIsConnected: Bool {
return state == .Connected
}
var legacyUUID: NSUUID {
return identifier as NSUUID
}
}
Callers can then migrate incrementally: newer code uses the supported API directly, while older code depends on a compatibility surface that is easy to find and eventually remove.
Keep the shim narrow
- Use the peripheral state as the source of truth instead of maintaining a second connection flag.
- Keep identifier conversion at the boundary where legacy code needs it.
- Build against the oldest and newest supported SDKs, and test reconnect and disconnect paths on real devices.
- Remove the adapter once downstream SDKs and application call sites have moved to the current names.
The useful part of an extension is not that it hides an API change forever. It gives a team one controlled place to absorb the change, verify behavior, and migrate without duplicating compatibility logic throughout the application.
