corebluetooth
Core Bluetooth
Bluetooth Low Energy on Apple platforms: discovering and talking to BLE peripherals (central role) and advertising your own services (peripheral role). The deep API reference — full central/peripheral managers, GATT, async/await wrappers, notifications via AsyncStream, SwiftUI patterns, background/state-restoration, and battery/security practices — lives in references/guide.md. This file is the decision and discipline layer: read it first, open the guide for specifics.
Dials
Set these explicitly at the start; they change what "correct" means.
ROLE—central(default; you scan for and drive remote peripherals) ·peripheral(CBPeripheralManager; your device advertises services and answers reads/writes) ·both(device-to-device).LIFECYCLE—foreground(default; scan/connect only while the app is active) ·background(UIBackgroundModes=bluetooth-central/bluetooth-peripheral+ state preservation/restoration with a restore identifier).PAIRING_UX—manual(your own scan list + connect flow, full control) ·accessorysetupkit(iOS 18+ system discovery sheet for a known accessory — better UX, scoped permission).
When to use
Building or reviewing any BLE code that talks to Core Bluetooth directly: scanning, connecting, discovering services/characteristics, reading/writing/notifying, or advertising as a peripheral. If the task is purely the onboarding/pairing UX for a specific accessory, prefer AccessorySetupKit and only drop to raw Core Bluetooth for the data plane.