core-bluetooth
Build direct Bluetooth Low Energy workflows with Core Bluetooth. Use when implementing BLE central or peripheral GATT communication, scanning or connecting with CBCentralManager, discovering services and characteristics, reading/writing/subscribing with CBPeripheral, publishing local services with CBPeripheralManager, handling Bluetooth authorization, background BLE modes, state restoration, write flow control, or CBUUID-based workflows. For privacy-preserving accessory setup/picker flows, use a
Security Assessment
About core-bluetooth
The core-bluetooth skill provides comprehensive guidance for building Bluetooth Low Energy (BLE) workflows using Apple's Core Bluetooth framework. It enables developers to implement both central role functionality (scanning for and connecting to BLE peripherals) and peripheral role functionality (advertising services to other devices). This skill addresses the complexity of managing BLE communication, handling state transitions, authorization flows, and the intricacies of GATT (Generic Attribute Profile) operations including service discovery, characteristic interactions, and data exchange.
The skill covers essential BLE capabilities including scanning for peripherals with service filtering, establishing connections, discovering services and characteristics, performing read/write operations, subscribing to notifications, and implementing flow control for write operations. It also addresses advanced features like background BLE modes for continued operation when the app is not in the foreground, state restoration for recovering BLE state after app termination, and proper handling of Bluetooth authorization states. The documentation emphasizes proper resource management, such as retaining peripheral references and managing delegate lifecycles.
This skill is designed for iOS developers building applications that communicate with BLE devices such as fitness trackers, medical sensors, smart home accessories, or custom hardware. It targets Swift 6.3 and iOS 26+, providing modern API usage patterns. The skill is particularly valuable when direct GATT-level communication is required, while noting that the accessorysetupkit skill should be used first for privacy-preserving accessory discovery and setup flows, with core-bluetooth handling the subsequent communication layer.
FAQ
When should I use core-bluetooth versus accessorysetupkit?
Use accessorysetupkit for privacy-preserving accessory discovery and initial setup flows. Once the accessory is set up, use core-bluetooth for the actual GATT communication, service discovery, and data exchange with the BLE device.
What iOS version and Swift version does this skill target?
This skill targets Swift 6.3 and iOS 26+. The patterns and APIs documented are designed for modern iOS development with the latest Core Bluetooth framework capabilities.
What Info.plist keys are required for Bluetooth functionality?
You must include NSBluetoothAlwaysUsageDescription to explain why your app uses Bluetooth. For background operation, add UIBackgroundModes with bluetooth-central for scanning/connecting in the background, or bluetooth-peripheral for background advertising.
How do I handle Bluetooth authorization in Core Bluetooth?
Core Bluetooth has no explicit permission request API. Add the NSBluetoothAlwaysUsageDescription key, create the CBCentralManager when ready for Bluetooth access, then check manager.authorization and manager.state. Wait for .poweredOn state before performing any BLE operations.
What are the most common mistakes when working with Core Bluetooth?
The most critical mistake is failing to retain discovered CBPeripheral instances, which causes them to be deallocated. Always store a strong reference to peripherals you want to connect to. Other common issues include scanning before the manager reaches .poweredOn state and not properly managing delegate lifecycles.
Install core-bluetooth
Quick Setup:
- Copy the skill folder to
.claude/skills/ - Claude will automatically detect and use the skill
Repository
dpearson2699/swift-ios-skills