apple-ble-core-bluetoothlisted
Install: claude install-skill ttamakijp/dev-templates
# Skill: Apple BLE / CoreBluetooth patterns
Apple CoreBluetooth を使う iOS / macOS / iPadOS / watchOS / tvOS / visionOS
プロジェクトで、**state restoration / typed error / nil ガード / 12 BLE
観察点** を実装段階で組込むための skill。
[[ADR-0037]] rule scope policy により BLE 固有の framework 特有規約は
rule ([[build-and-debug-ios]]) から本 skill へ切出された。[[ADR-0036]]
`--suggest-skills` mode が `CoreBluetooth` import 検出時に提案する。
## When to invoke
- iOS / macOS / tvOS 等のプロジェクトで CoreBluetooth を import している
- BLE 切断 / 再接続 / encryption / state restoration の実装に着手する
- BLE 観察 (Console.app / `log show`) で「何を見ればよいか」を整理したい
- ADR-0036 `--suggest-skills` mode から提案を受けた
## 要件
- BLE state restoration ([Apple Developer: Core Bluetooth Background
Processing](https://developer.apple.com/documentation/corebluetooth)) を
前提に central / peripheral manager を設計する
- CBATTError 等の raw error を **typed app-level enum** にマッピングする
- peripheral 参照の nil ガードを実装段階で組込む
- 12 観察点を 1 つの category (`"ble"`) で横断検索可能にする
## 手順
### Step 1: CBCentralManager の state restoration 必須化 (Apple 公式 API)
```swift
import CoreBluetooth
let options: [String: Any] = [
CBCentralManagerOptionRestoreIdentifierKey: "<reverse-dns>.ble.central",
CBCentralManagerOptionShowPowerAlertKey: true,
]
self.central = CBCentralManager(delegate: self, queue: queue, options: options)
```
- `CBCentralManagerOptionRestoreIdentifierKey` は **アプリ内で一意**
(複数 central 同居なら個別 identifier)
- `centralManager(_:willRestoreState:)` を **必ず実装**:
- `dict[CBCentralManagerRestoredStatePeriphera