Skip to content

Add @available attributes for Logger APIs in BluetoothManager extensions#3

Closed
Copilot wants to merge 2 commits intomainfrom
copilot/add-availability-attributes
Closed

Add @available attributes for Logger APIs in BluetoothManager extensions#3
Copilot wants to merge 2 commits intomainfrom
copilot/add-availability-attributes

Conversation

Copy link

Copilot AI commented Jan 19, 2026

Swift compiler errors occur when using Logger and OSLogMessage APIs (macOS 11.0+/iOS 14.0+) without explicit availability annotations.

Changes

  • Added @available(macOS 11.0, iOS 14.0, watchOS 7.0, *) to CBCentralManagerDelegate extension (line 197)
  • Added @available(macOS 11.0, iOS 14.0, watchOS 7.0, *) to CBPeripheralDelegate extension (line 230)

Both extensions use Logger.main.info() calls throughout their delegate methods, triggering availability errors without these attributes.

@available(macOS 11.0, iOS 14.0, watchOS 7.0, *)
extension BluetoothManager: CBCentralManagerDelegate {
    public func centralManagerDidUpdateState(_ central: CBCentralManager) {
        // ... Logger calls
    }
}

@available(macOS 11.0, iOS 14.0, watchOS 7.0, *)
extension BluetoothManager: CBPeripheralDelegate {
    public func peripheral(_ peripheral: CBPeripheral, didDiscoverCharacteristicsFor service: CBService, error: (any Error)?) {
        Logger.main.info("didDiscoverCharacteristicsFor service: \(service)")
        // ... more Logger calls
    }
}

The specified versions align with the project's iOS 14.0 deployment target.

Original prompt

Problem

The Swift build is failing with availability errors because Logger and OSLogMessage APIs require macOS 11.0+ (iOS 14.0+), but the code doesn't have proper @available attributes.

Current Errors

The build fails with errors like:

error: 'Logger' is only available in macOS 11.0 or newer
error: 'OSLogMessage' is only available in macOS 11.0 or newer
error: 'appendInterpolation(_:privacy:)' is only available in macOS 11.0 or newer

These errors occur in Improv-iOS/BluetoothManager.swift in the following extensions:

  • extension BluetoothManager: CBCentralManagerDelegate (starting at line 197)
  • extension BluetoothManager: CBPeripheralDelegate (starting at line 230)

Solution Required

Add @available attributes to both extensions that use Logger APIs:

For the CBCentralManagerDelegate extension (around line 197):

@available(macOS 11.0, iOS 14.0, watchOS 7.0, *)
extension BluetoothManager: CBCentralManagerDelegate {
    // existing methods...
}

For the CBPeripheralDelegate extension (around line 230):

@available(macOS 11.0, iOS 14.0, watchOS 7.0, *)
extension BluetoothManager: CBPeripheralDelegate {
    // existing methods...
}

Files to Modify

  • Improv-iOS/BluetoothManager.swift

Context

The project's deployment target is macOS 12.0 and iOS 15.0, which are both >= the required versions for Logger (macOS 11.0, iOS 14.0). Adding these availability attributes satisfies the Swift compiler's requirements while maintaining compatibility with the project's deployment targets.

Reference: Failed build at https://github.com/improv-wifi/sdk-iOS/actions/runs/21142229137/workflow?pr=2

This pull request was created from Copilot chat.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: bgoncal <5808343+bgoncal@users.noreply.github.com>
Copilot AI changed the title [WIP] Add @available attributes for Logger APIs Add @available attributes for Logger APIs in BluetoothManager extensions Jan 19, 2026
Copilot AI requested a review from bgoncal January 19, 2026 15:15
@bgoncal bgoncal closed this Jan 19, 2026
@bgoncal bgoncal deleted the copilot/add-availability-attributes branch January 19, 2026 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments