[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M782N014PNE5HCQQE6N83PHF":3,"skill-same:01M782N014PNE5HCQQE6N83PHF":47},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":29,"ownerHtmlUrl":30,"ownerBlogUrl":6,"ownerDescription":31,"updatedAt":32,"install":33,"resources":46},"01M782N014PNE5HCQQE6N83PHF","accessorysetupkit",null,"Discover and configure Bluetooth and Wi-Fi accessories using AccessorySetupKit. Use when presenting a privacy-preserving accessory picker, defining discovery descriptors for BLE or Wi-Fi devices, handling accessory session events, migrating from CoreBluetooth permission-based scanning, or setting up accessories without requiring broad Bluetooth permissions.","Lord1Egypt\u002Fawesome-skill-forge","Lord1Egypt","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F99746359?v=4","01M7592YDNT0XK9WJ0T2MQVPDN","Mohamed Mounir Ali AL Keshita","01M75GRFNHC8VZNWEB8DKDE433",3,"MIT","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fcommunity\u002Fskills_sh\u002Fs\u002Fskills-sh_dpearson2699_swift-ios-skills_accessorysetupkit\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: accessorysetupkit\ndescription: \"Discover and configure Bluetooth and Wi-Fi accessories using AccessorySetupKit. Use when presenting a privacy-preserving accessory picker, defining discovery descriptors for BLE or Wi-Fi devices, handling accessory session events, migrating from CoreBluetooth permission-based scanning, or setting up accessories without requiring broad Bluetooth permissions.\"\n---\n\n# AccessorySetupKit\n\nPrivacy-preserving accessory discovery and setup for Bluetooth and Wi-Fi\ndevices. Replaces broad Bluetooth\u002FWi-Fi permission prompts with a\nsystem-provided picker that grants per-accessory access with a single tap.\nAvailable iOS 18+ \u002F Swift 6.3.\n\nAfter setup, apps continue using CoreBluetooth and NetworkExtension for\ncommunication. AccessorySetupKit handles only the discovery and authorization\nstep.\n\n## Contents\n\n- [Setup and Entitlements](#setup-and-entitlements)\n- [Discovery Descriptors](#discovery-descriptors)\n- [Presenting the Picker](#presenting-the-picker)\n- [Event Handling](#event-handling)\n- [Bluetooth Accessories](#bluetooth-accessories)\n- [Wi-Fi Accessories](#wi-fi-accessories)\n- [Migration from CoreBluetooth](#migration-from-corebluetooth)\n- [Common Mistakes](#common-mistakes)\n- [Review Checklist](#review-checklist)\n- [References](#references)\n\n## Setup and Entitlements\n\n### Info.plist Configuration\n\nAdd these keys to the app's Info.plist:\n\n| Key | Type | Purpose |\n|---|---|---|\n| `NSAccessorySetupSupports` | `[String]` | Required. Array containing `Bluetooth` and\u002For `WiFi` |\n| `NSAccessorySetupBluetoothServices` | `[String]` | Service UUIDs the app discovers (Bluetooth) |\n| `NSAccessorySetupBluetoothNames` | `[String]` | Bluetooth names or substrings to match |\n| `NSAccessorySetupBluetoothCompanyIdentifiers` | `[String]` | Two-byte Bluetooth company identifiers |\n\nThe Bluetooth-specific keys must match the values used in `ASDiscoveryDescriptor`.\nIf the app uses identifiers, names, or services not declared in Info.plist, the\napp crashes during AccessorySetupKit discovery. For Wi-Fi accessories, include\n`WiFi` in `NSAccessorySetupSupports` and match the descriptor's SSID rule.\n\n### No Bluetooth Permission Required\n\nWhen an app declares `NSAccessorySetupSupports` with `Bluetooth`, creating a\n`CBCentralManager` no longer triggers the system Bluetooth permission dialog.\nThe central manager's state transitions to `poweredOn` only when the app has\nat least one paired accessory via AccessorySetupKit.\n\n## Discovery Descriptors\n\n`ASDiscoveryDescriptor` defines the matching criteria for finding accessories.\nThe system matches scanned results against all rules in the descriptor to\nfilter for the target accessory.\n\n### Bluetooth Descriptor\n\n```swift\nimport AccessorySetupKit\nimport CoreBluetooth\n\nvar descriptor = ASDiscoveryDescriptor()\ndescriptor.bluetoothServiceUUID = CBUUID(string: \"12345678-1234-1234-1234-123456789ABC\")\ndescriptor.bluetoothNameSubstring = \"MyDevice\"\ndescriptor.bluetoothRange = .immediate  \u002F\u002F Only nearby devices\n```\n\nA Bluetooth descriptor needs at least one of `bluetoothCompanyIdentifier` or\n`bluetoothServiceUUID`. Add narrower matchers as needed:\n\n- `bluetoothNameSubstring` with a company identifier or service UUID\n- `bluetoothManufacturerDataBlob` and `bluetoothManufacturerDataMask` with a\n  company identifier; blob and mask must have the same length\n- `bluetoothServiceDataBlob` and `bluetoothServiceDataMask` with a service UUID;\n  blob and mask must have the same length\n\n### Wi-Fi Descriptor\n\n```swift\nvar descriptor = ASDiscoveryDescriptor()\ndescriptor.ssid = \"MyAccessory-Network\"\n\u002F\u002F OR use a prefix:\n\u002F\u002F descriptor.ssidPrefix = \"MyAccessory-\"\n```\n\nSupply either `ssid` or `ssidPrefix`, not both. The app crashes if both are set.\nThe `ssidPrefix` must have a non-zero length.\n\n### Bluetooth Range\n\nControl the physical proximity required for discovery:\n\n| Value | Behavior |\n|---|---|\n| `.default` | Standard Bluetooth range |\n| `.immediate` | Only accessories in close physical proximity |\n\n### Support Options\n\nSet `supportedOptions` on the descriptor to declare the accessory's capabilities:\n\n```swift\ndescriptor.supportedOptions = [.bluetoothPairingLE, .bluetoothTransportBridging]\n```\n\n| Option | Purpose |\n|---|---|\n| `.bluetoothPairingLE` | BLE pairing support |\n| `.bluetoothTransportBridging` | Bluetooth transport bridging |\n| `.bluetoothHID` | Bluetooth HID device |\n\n## Presenting the Picker\n\n### Creating the Session\n\nCreate and activate an `ASAccessorySession` to manage discovery lifecycle. Wait for `.activated` before reading `session.accessories` or presenting the picker:\n\n```swift\nimport AccessorySetupKit\n\nfinal class AccessoryManager {\n    private let session = ASAccessorySession()\n\n    func start() {\n        session.activate(on: .main) { [weak self] event in\n            self?.handleEvent(event)\n        }\n    }\n\n    private func handleEvent(_ event: ASAccessoryEvent) {\n        switch event.eventType {\n        case .activated:\n            \u002F\u002F Session ready. Check session.accessories for previously paired devices.\n            break\n        case .accessoryAdded:\n            guard let accessory = event.accessory else { return }\n            handleAccessoryAdded(accessory)\n        case .accessoryChanged:\n            \u002F\u002F Accessory properties changed (e.g., display name updated in Settings)\n            break\n        case .accessoryRemoved:\n            \u002F\u002F Accessory removed by user or app\n            break\n        case .invalidated:\n            \u002F\u002F Session invalidated, cannot be reused\n            break\n        @unknown default:\n            break\n        }\n    }\n}\n```\n\n### Showing the Picker\n\nCreate `ASPickerDisplayItem` instances with a name, product image, and\ndiscovery descriptor, then pass them to the activated session:\n\n```swift\nfunc showAccessoryPicker() {\n    var descriptor = ASDiscoveryDescriptor()\n    descriptor.bluetoothServiceUUID = CBUUID(string: \"ABCD1234-0000-1000-8000-00805F9B34FB\")\n\n    guard let image = UIImage(named: \"my-accessory\") else { return }\n\n    let item = ASPickerDisplayItem(\n        name: \"My Bluetooth Accessory\",\n        productImage: image,\n        descriptor: descriptor\n    )\n\n    session.showPicker(for: [item]) { error in\n        if let error {\n            print(\"Picker failed: \\(error.localizedDescription)\")\n        }\n    }\n}\n```\n\nThe picker runs in a separate system process. It shows each matching device\nas a separate item. When multiple devices match a given descriptor, the picker\ncreates a horizontal carousel.\n\n### Setup Options\n\nConfigure picker behavior per display item:\n\n```swift\nvar item = ASPickerDisplayItem(\n    name: \"My Accessory\",\n    productImage: image,\n    descriptor: descriptor\n)\nitem.setupOptions = [.rename, .confirmAuthorization]\n```\n\n| Option | Effect |\n|---|---|\n| `.rename` | Allow renaming the accessory during setup |\n| `.confirmAuthorization` | Show authorization confirmation before setup |\n| `.finishInApp` | Signal that setup continues in the app after pairing |\n\n### Product Images\n\nThe picker displays images in a 180x120 point container. Best practices:\n\n- Use high-resolution images for all screen scale factors\n- Use transparent backgrounds for correct light\u002Fdark mode appearance\n- Adjust transparent borders as padding to control apparent accessory size\n- Test in both light and dark mode\n\n## Event Handling\n\n### Event Types\n\nThe session delivers `ASAccessoryEvent` objects through the event handler:\n\n| Event | When |\n|---|---|\n| `.activated` | Session is active, query `session.accessories` |\n| `.accessoryAdded` | User selected an accessory in the picker |\n| `.accessoryChanged` | Accessory properties updated (e.g., renamed) |\n| `.accessoryRemoved` | Accessory removed from system |\n| `.invalidated` | Session invalidated, create a new one |\n| `.migrationComplete` | Migration of legacy accessories completed |\n| `.pickerDidPresent` | Picker appeared on screen |\n| `.pickerDidDismiss` | Picker dismissed |\n| `.pickerSetupBridging` | Transport bridging setup in progress |\n| `.pickerSetupPairing` | Bluetooth pairing in progress |\n| `.pickerSetupFailed` | Setup failed |\n| `.pickerSetupRename` | User is renaming the accessory |\n| `.accessoryDiscovered` | New accessory found (custom filtering mode) |\n\n### Coordinating Picker Dismissal\n\nWhen the user selects an accessory, `.accessoryAdded` fires before\n`.pickerDidDismiss`. To show custom setup UI after the picker closes, store the\naccessory on the first event and act on it after dismissal:\n\n```swift\nprivate var pendingAccessory: ASAccessory?\n\nprivate func handleEvent(_ event: ASAccessoryEvent) {\n    switch event.eventType {\n    case .accessoryAdded:\n        pendingAccessory = event.accessory\n    case .pickerDidDismiss:\n        if let accessory = pendingAccessory {\n            pendingAccessory = nil\n            beginCustomSetup(accessory)\n        }\n    @unknown default:\n        break\n    }\n}\n```\n\n## Bluetooth Accessories\n\nAfter an accessory is added via the picker, use CoreBluetooth to communicate.\nThe `bluetoothIdentifier` on the `ASAccessory` maps to a `CBPeripheral`.\n\n```swift\nimport CoreBluetooth\n\nfunc handleAccessoryAdded(_ accessory: ASAccessory) {\n    guard let btIdentifier = accessory.bluetoothIdentifier else { return }\n\n    \u002F\u002F Create CBCentralManager — no Bluetooth permission prompt appears\n    let centralManager = CBCentralManager(delegate: self, queue: nil)\n\n    \u002F\u002F After poweredOn, retrieve the peripheral\n    let peripherals = centralManager.retrievePeripherals(\n        withIdentifiers: [btIdentifier]\n    )\n    guard let peripheral = peripherals.first else { return }\n    centralManager.connect(peripheral, options: nil)\n}\n```\n\nKey points:\n\n- `CBCentralManager` state reaches `.poweredOn` only when the app has paired accessories\n- Scanning with `scanForPeripherals(withServices:)` returns only\n  accessories paired through AccessorySetupKit\n- No `NSBluetoothAlwaysUsageDescription` is needed when using AccessorySetupKit\n  exclusively\n\n## Wi-Fi Accessories\n\nFor Wi-Fi accessories, the `ssid` on the `ASAccessory` identifies the network.\nUse `NEHotspotConfiguration` from NetworkExtension to join it:\n\n```swift\nimport NetworkExtension\n\nfunc handleWiFiAccessoryAdded(_ accessory: ASAccessory) {\n    guard let ssid = accessory.ssid else { return }\n\n    let configuration = NEHotspotConfiguration(ssid: ssid)\n    NEHotspotConfigurationManager.shared.apply(configuration) { error in\n        if let error {\n            print(\"Wi-Fi join failed: \\(error.localizedDescription)\")\n        }\n    }\n}\n```\n\nBecause the accessory was discovered through AccessorySetupKit, joining the\nnetwork does not trigger the standard Wi-Fi access prompt.\n\n## Migration from CoreBluetooth\n\nApps with existing CoreBluetooth-authorized accessories can migrate them to\nAccessorySetupKit using `ASMigrationDisplayItem`. This is a one-time operation\nthat registers known accessories in the new system.\n\n```swift\nfunc migrateExistingAccessories() {\n    guard let image = UIImage(named: \"my-accessory\") else { return }\n\n    var descriptor = ASDiscoveryDescriptor()\n    descriptor.bluetoothServiceUUID = CBUUID(string: \"ABCD1234-0000-1000-8000-00805F9B34FB\")\n\n    let migrationItem = ASMigrationDisplayItem(\n        name: \"My Accessory\",\n        productImage: image,\n        descriptor: descriptor\n    )\n    \u002F\u002F Set the peripheral identifier from CoreBluetooth\n    migrationItem.peripheralIdentifier = existingPeripheralUUID\n\n    \u002F\u002F For Wi-Fi accessories:\n    \u002F\u002F migrationItem.hotspotSSID = \"MyAccessory-WiFi\"\n\n    session.showPicker(for: [migrationItem]) { error in\n        if let error {\n            print(\"Migration failed: \\(error.localizedDescription)\")\n        }\n    }\n}\n```\n\nMigration rules:\n\n- If `showPicker` contains only migration items, the system shows an\n  informational page instead of a discovery picker\n- If migration items are mixed with regular display items, migration happens\n  only when a new accessory is discovered and set up\n- Do not initialize `CBCentralManager` before migration completes — doing so\n  causes an error and the picker fails to appear\n- The session receives `.migrationComplete` when migration finishes\n\n## Common Mistakes\n\n### DON'T: Omit Info.plist keys for Bluetooth discovery\n\nThe app crashes if it uses identifiers, names, or services in descriptors that\nare not declared in Info.plist.\n\n```swift\n\u002F\u002F WRONG — service UUID not in NSAccessorySetupBluetoothServices\nvar descriptor = ASDiscoveryDescriptor()\ndescriptor.bluetoothServiceUUID = CBUUID(string: \"UNDECLARED-UUID\")\nsession.showPicker(for: [item]) { _ in }  \u002F\u002F Crash\n\n\u002F\u002F CORRECT — declare all UUIDs in Info.plist first\n\u002F\u002F Info.plist: NSAccessorySetupBluetoothServices = [\"ABCD1234-...\"]\nvar descriptor = ASDiscoveryDescriptor()\ndescriptor.bluetoothServiceUUID = CBUUID(string: \"ABCD1234-...\")\n```\n\n### DON'T: Set both ssid and ssidPrefix\n\n```swift\n\u002F\u002F WRONG — crashes at runtime\nvar descriptor = ASDiscoveryDescriptor()\ndescriptor.ssid = \"MyNetwork\"\ndescriptor.ssidPrefix = \"My\"  \u002F\u002F Cannot set both\n\n\u002F\u002F CORRECT — use one or the other\nvar descriptor = ASDiscoveryDescriptor()\ndescriptor.ssid = \"MyNetwork\"\n```\n\n### DON'T: Initialize CBCentralManager before migration\n\n```swift\n\u002F\u002F WRONG — migration fails, picker does not appear\nlet central = CBCentralManager(delegate: self, queue: nil)\nsession.showPicker(for: [migrationItem]) { error in\n    \u002F\u002F error is non-nil\n}\n\n\u002F\u002F CORRECT — wait for .migrationComplete before using CoreBluetooth\nsession.activate(on: .main) { event in\n    if event.eventType == .migrationComplete {\n        let central = CBCentralManager(delegate: self, queue: nil)\n    }\n}\n```\n\n### DON'T: Show the picker without user intent\n\n```swift\n\u002F\u002F WRONG — picker appears unexpectedly on app launch\noverride func viewDidLoad() {\n    super.viewDidLoad()\n    session.showPicker(for: items) { _ in }\n}\n\n\u002F\u002F CORRECT — bind picker to a user action\n@IBAction func addAccessoryTapped(_ sender: UIButton) {\n    session.showPicker(for: items) { _ in }\n}\n```\n\n### DON'T: Reuse an invalidated session\n\n```swift\n\u002F\u002F WRONG — session is dead after invalidation\nsession.showPicker(for: items) { _ in }  \u002F\u002F No effect\n\n\u002F\u002F CORRECT — create a new session\nlet newSession = ASAccessorySession()\nnewSession.activate(on: .main) { event in\n    \u002F\u002F Handle events\n}\n```\n\n## Review Checklist\n\n- [ ] `NSAccessorySetupSupports` added to Info.plist with `Bluetooth` and\u002For `WiFi`\n- [ ] Bluetooth-specific plist keys (`NSAccessorySetupBluetoothServices`, `NSAccessorySetupBluetoothNames`, `NSAccessorySetupBluetoothCompanyIdentifiers`) match descriptor values\n- [ ] Session activated before calling `showPicker`\n- [ ] Event handler uses `[weak self]` to avoid retain cycles\n- [ ] All `ASAccessoryEventType` cases handled, including `@unknown default`\n- [ ] Product images use transparent backgrounds and appropriate resolution\n- [ ] `ssid` and `ssidPrefix` are never set simultaneously on a descriptor\n- [ ] Picker presentation tied to explicit user action, not automatic\n- [ ] `CBCentralManager` not initialized until after migration completes (if migrating)\n- [ ] `bluetoothIdentifier` or `ssid` from `ASAccessory` used to connect post-setup\n- [ ] Invalidated sessions replaced with new instances\n- [ ] Accessory removal events handled to clean up app state\n\n## References\n\n- Extended patterns (custom filtering, batch setup, removal handling, error recovery): [references\u002Faccessorysetupkit-patterns.md](references\u002Faccessorysetupkit-patterns.md)\n- [AccessorySetupKit framework](https:\u002F\u002Fsosumi.ai\u002Fdocumentation\u002Faccessorysetupkit)\n- [ASAccessorySession](https:\u002F\u002Fsosumi.ai\u002Fdocumentation\u002Faccessorysetupkit\u002Fasaccessorysession)\n- [ASDiscoveryDescriptor](https:\u002F\u002Fsosumi.ai\u002Fdocumentation\u002Faccessorysetupkit\u002Fasdiscoverydescriptor)\n- [ASPickerDisplayItem](https:\u002F\u002Fsosumi.ai\u002Fdocumentation\u002Faccessorysetupkit\u002Faspickerdisplayitem)\n- [ASAccessory](https:\u002F\u002Fsosumi.ai\u002Fdocumentation\u002Faccessorysetupkit\u002Fasaccessory)\n- [ASAccessoryEvent](https:\u002F\u002Fsosumi.ai\u002Fdocumentation\u002Faccessorysetupkit\u002Fasaccessoryevent)\n- [ASMigrationDisplayItem](https:\u002F\u002Fsosumi.ai\u002Fdocumentation\u002Faccessorysetupkit\u002Fasmigrationdisplayitem)\n- [Discovering and configuring accessories](https:\u002F\u002Fsosumi.ai\u002Fdocumentation\u002Faccessorysetupkit\u002Fdiscovering-and-configuring-accessories)\n- [Setting up and authorizing a Bluetooth accessory](https:\u002F\u002Fsosumi.ai\u002Fdocumentation\u002Faccessorysetupkit\u002Fsetting-up-and-authorizing-a-bluetooth-accessory)\n- [Meet AccessorySetupKit — WWDC24](https:\u002F\u002Fsosumi.ai\u002Fvideos\u002Fplay\u002Fwwdc2024\u002F10203\u002F)\n","# AccessorySetupKit\n\nPrivacy-preserving accessory discovery and setup for Bluetooth and Wi-Fi\ndevices. Replaces broad Bluetooth\u002FWi-Fi permission prompts with a\nsystem-provided picker that grants per-accessory access with a single tap.\nAvailable iOS 18+ \u002F Swift 6.3.\n\nAfter setup, apps continue using CoreBluetooth and NetworkExtension for\ncommunication. AccessorySetupKit handles only the discovery and authorization\nstep.\n\n## Contents\n\n- [Setup and Entitlements](#setup-and-entitlements)\n- [Discovery Descriptors](#discovery-descriptors)\n- [Presenting the Picker](#presenting-the-picker)\n- [Event Handling](#event-handling)\n- [Bluetooth Accessories](#bluetooth-accessories)\n- [Wi-Fi Accessories](#wi-fi-accessories)\n- [Migration from CoreBluetooth](#migration-from-corebluetooth)\n- [Common Mistakes](#common-mistakes)\n- [Review Checklist](#review-checklist)\n- [References](#references)\n\n## Setup and Entitlements\n\n### Info.plist Configuration\n\nAdd these keys to the app's Info.plist:\n\n| Key | Type | Purpose |\n|---|---|---|\n| `NSAccessorySetupSupports` | `[String]` | Required. Array containing `Bluetooth` and\u002For `WiFi` |\n| `NSAccessorySetupBluetoothServices` | `[String]` | Service UUIDs the app discovers (Bluetooth) |\n| `NSAccessorySetupBluetoothNames` | `[String]` | Bluetooth names or substrings to match |\n| `NSAccessorySetupBluetoothCompanyIdentifiers` | `[String]` | Two-byte Bluetooth company identifiers |\n\nThe Bluetooth-specific keys must match the values used in `ASDiscoveryDescriptor`.\nIf the app uses identifiers, names, or services not declared in Info.plist, the\napp crashes during AccessorySetupKit discovery. For Wi-Fi accessories, include\n`WiFi` in `NSAccessorySetupSupports` and match the descriptor's SSID rule.\n\n### No Bluetooth Permission Required\n\nWhen an app declares `NSAccessorySetupSupports` with `Bluetooth`, creating a\n`CBCentralManager` no longer triggers the system Bluetooth permission dialog.\nThe central manager's state transitions to `poweredOn` only when the app has\nat least one paired accessory via AccessorySetupKit.\n\n## Discovery Descriptors\n\n`ASDiscoveryDescriptor` defines the matching criteria for finding accessories.\nThe system matches scanned results against all rules in the descriptor to\nfilter for the target accessory.\n\n### Bluetooth Descriptor\n\n```swift\nimport AccessorySetupKit\nimport CoreBluetooth\n\nvar descriptor = ASDiscoveryDescriptor()\ndescriptor.bluetoothServiceUUID = CBUUID(string: \"12345678-1234-1234-1234-123456789ABC\")\ndescriptor.bluetoothNameSubstring = \"MyDevice\"\ndescriptor.bluetoothRange = .immediate  \u002F\u002F Only nearby devices\n```\n\nA Bluetooth descriptor needs at least one of `bluetoothCompanyIdentifier` or\n`bluetoothServiceUUID`. Add narrower matchers as needed:\n\n- `bluetoothNameSubstring` with a company identifier or service UUID\n- `bluetoothManufacturerDataBlob` and `bluetoothManufacturerDataMask` with a\n  company identifier; blob and mask must have the same length\n- `bluetoothServiceDataBlob` and `bluetoothServiceDataMask` with a service UUID;\n  blob and mask must have the same length\n\n### Wi-Fi Descriptor\n\n```swift\nvar descriptor = ASDiscoveryDescriptor()\ndescriptor.ssid = \"MyAccessory-Network\"\n\u002F\u002F OR use a prefix:\n\u002F\u002F descriptor.ssidPrefix = \"MyAccessory-\"\n```\n\nSupply either `ssid` or `ssidPrefix`, not both. The app crashes if both are set.\nThe `ssidPrefix` must have a non-zero length.\n\n### Bluetooth Range\n\nControl the physical proximity required for discovery:\n\n| Value | Behavior |\n|---|---|\n| `.default` | Standard Bluetooth range |\n| `.immediate` | Only accessories in close physical proximity |\n\n### Support Options\n\nSet `supportedOptions` on the descriptor to declare the accessory's capabilities:\n\n```swift\ndescriptor.supportedOptions = [.bluetoothPairingLE, .bluetoothTransportBridging]\n```\n\n| Option | Purpose |\n|---|---|\n| `.bluetoothPairingLE` | BLE pairing support |\n| `.bluetoothTransportBridging` | Bluetooth transport bridging |\n| `.bluetoothHID` | Bluetooth HID device |\n\n## Presenting the Picker\n\n### Creating the Session\n\nCreate and activate an `ASAccessorySession` to manage discovery lifecycle. Wait for `.activated` before reading `session.accessories` or presenting the picker:\n\n```swift\nimport AccessorySetupKit\n\nfinal class AccessoryManager {\n    private let session = ASAccessorySession()\n\n    func start() {\n        session.activate(on: .main) { [weak self] event in\n            self?.handleEvent(event)\n        }\n    }\n\n    private func handleEvent(_ event: ASAccessoryEvent) {\n        switch event.eventType {\n        case .activated:\n            \u002F\u002F Session ready. Check session.accessories for previously paired devices.\n            break\n        case .accessoryAdded:\n            guard let accessory = event.accessory else { return }\n            handleAccessoryAdded(accessory)\n        case .accessoryChanged:\n            \u002F\u002F Accessory properties changed (e.g., display name updated in Settings)\n            break\n        case .accessoryRemoved:\n            \u002F\u002F Accessory removed by user or app\n            break\n        case .invalidated:\n            \u002F\u002F Session invalidated, cannot be reused\n            break\n        @unknown default:\n            break\n        }\n    }\n}\n```\n\n### Showing the Picker\n\nCreate `ASPickerDisplayItem` instances with a name, product image, and\ndiscovery descriptor, then pass them to the activated session:\n\n```swift\nfunc showAccessoryPicker() {\n    var descriptor = ASDiscoveryDescriptor()\n    descriptor.bluetoothServiceUUID = CBUUID(string: \"ABCD1234-0000-1000-8000-00805F9B34FB\")\n\n    guard let image = UIImage(named: \"my-accessory\") else { return }\n\n    let item = ASPickerDisplayItem(\n        name: \"My Bluetooth Accessory\",\n        productImage: image,\n        descriptor: descriptor\n    )\n\n    session.showPicker(for: [item]) { error in\n        if let error {\n            print(\"Picker failed: \\(error.localizedDescription)\")\n        }\n    }\n}\n```\n\nThe picker runs in a separate system process. It shows each matching device\nas a separate item. When multiple devices match a given descriptor, the picker\ncreates a horizontal carousel.\n\n### Setup Options\n\nConfigure picker behavior per display item:\n\n```swift\nvar item = ASPickerDisplayItem(\n    name: \"My Accessory\",\n    productImage: image,\n    descriptor: descriptor\n)\nitem.setupOptions = [.rename, .confirmAuthorization]\n```\n\n| Option | Effect |\n|---|---|\n| `.rename` | Allow renaming the accessory during setup |\n| `.confirmAuthorization` | Show authorization confirmation before setup |\n| `.finishInApp` | Signal that setup continues in the app after pairing |\n\n### Product Images\n\nThe picker displays images in a 180x120 point container. Best practices:\n\n- Use high-resolution images for all screen scale factors\n- Use transparent backgrounds for correct light\u002Fdark mode appearance\n- Adjust transparent borders as padding to control apparent accessory size\n- Test in both light and dark mode\n\n## Event Handling\n\n### Event Types\n\nThe session delivers `ASAccessoryEvent` objects through the event handler:\n\n| Event | When |\n|---|---|\n| `.activated` | Session is active, query `session.accessories` |\n| `.accessoryAdded` | User selected an accessory in the picker |\n| `.accessoryChanged` | Accessory properties updated (e.g., renamed) |\n| `.accessoryRemoved` | Accessory removed from system |\n| `.invalidated` | Session invalidated, create a new one |\n| `.migrationComplete` | Migration of legacy accessories completed |\n| `.pickerDidPresent` | Picker appeared on screen |\n| `.pickerDidDismiss` | Picker dismissed |\n| `.pickerSetupBridging` | Transport bridging setup in progress |\n| `.pickerSetupPairing` | Bluetooth pairing in progress |\n| `.pickerSetupFailed` | Setup failed |\n| `.pickerSetupRename` | User is renaming the accessory |\n| `.accessoryDiscovered` | New accessory found (custom filtering mode) |\n\n### Coordinating Picker Dismissal\n\nWhen the user selects an accessory, `.accessoryAdded` fires before\n`.pickerDidDismiss`. To show custom setup UI after the picker closes, store the\naccessory on the first event and act on it after dismissal:\n\n```swift\nprivate var pendingAccessory: ASAccessory?\n\nprivate func handleEvent(_ event: ASAccessoryEvent) {\n    switch event.eventType {\n    case .accessoryAdded:\n        pendingAccessory = event.accessory\n    case .pickerDidDismiss:\n        if let accessory = pendingAccessory {\n            pendingAccessory = nil\n            beginCustomSetup(accessory)\n        }\n    @unknown default:\n        break\n    }\n}\n```\n\n## Bluetooth Accessories\n\nAfter an accessory is added via the picker, use CoreBluetooth to communicate.\nThe `bluetoothIdentifier` on the `ASAccessory` maps to a `CBPeripheral`.\n\n```swift\nimport CoreBluetooth\n\nfunc handleAccessoryAdded(_ accessory: ASAccessory) {\n    guard let btIdentifier = accessory.bluetoothIdentifier else { return }\n\n    \u002F\u002F Create CBCentralManager — no Bluetooth permission prompt appears\n    let centralManager = CBCentralManager(delegate: self, queue: nil)\n\n    \u002F\u002F After poweredOn, retrieve the peripheral\n    let peripherals = centralManager.retrievePeripherals(\n        withIdentifiers: [btIdentifier]\n    )\n    guard let peripheral = peripherals.first else { return }\n    centralManager.connect(peripheral, options: nil)\n}\n```\n\nKey points:\n\n- `CBCentralManager` state reaches `.poweredOn` only when the app has paired accessories\n- Scanning with `scanForPeripherals(withServices:)` returns only\n  accessories paired through AccessorySetupKit\n- No `NSBluetoothAlwaysUsageDescription` is needed when using AccessorySetupKit\n  exclusively\n\n## Wi-Fi Accessories\n\nFor Wi-Fi accessories, the `ssid` on the `ASAccessory` identifies the network.\nUse `NEHotspotConfiguration` from NetworkExtension to join it:\n\n```swift\nimport NetworkExtension\n\nfunc handleWiFiAccessoryAdded(_ accessory: ASAccessory) {\n    guard let ssid = accessory.ssid else { return }\n\n    let configuration = NEHotspotConfiguration(ssid: ssid)\n    NEHotspotConfigurationManager.shared.apply(configuration) { error in\n        if let error {\n            print(\"Wi-Fi join failed: \\(error.localizedDescription)\")\n        }\n    }\n}\n```\n\nBecause the accessory was discovered through AccessorySetupKit, joining the\nnetwork does not trigger the standard Wi-Fi access prompt.\n\n## Migration from CoreBluetooth\n\nApps with existing CoreBluetooth-authorized accessories can migrate them to\nAccessorySetupKit using `ASMigrationDisplayItem`. This is a one-time operation\nthat registers known accessories in the new system.\n\n```swift\nfunc migrateExistingAccessories() {\n    guard let image = UIImage(named: \"my-accessory\") else { return }\n\n    var descriptor = ASDiscoveryDescriptor()\n    descriptor.bluetoothServiceUUID = CBUUID(string: \"ABCD1234-0000-1000-8000-00805F9B34FB\")\n\n    let migrationItem = ASMigrationDisplayItem(\n        name: \"My Accessory\",\n        productImage: image,\n        descriptor: descriptor\n    )\n    \u002F\u002F Set the peripheral identifier from CoreBluetooth\n    migrationItem.peripheralIdentifier = existingPeripheralUUID\n\n    \u002F\u002F For Wi-Fi accessories:\n    \u002F\u002F migrationItem.hotspotSSID = \"MyAccessory-WiFi\"\n\n    session.showPicker(for: [migrationItem]) { error in\n        if let error {\n            print(\"Migration failed: \\(error.localizedDescription)\")\n        }\n    }\n}\n```\n\nMigration rules:\n\n- If `showPicker` contains only migration items, the system shows an\n  informational page instead of a discovery picker\n- If migration items are mixed with regular display items, migration happens\n  only when a new accessory is discovered and set up\n- Do not initialize `CBCentralManager` before migration completes — doing so\n  causes an error and the picker fails to appear\n- The session receives `.migrationComplete` when migration finishes\n\n## Common Mistakes\n\n### DON'T: Omit Info.plist keys for Bluetooth discovery\n\nThe app crashes if it uses identifiers, names, or services in descriptors that\nare not declared in Info.plist.\n\n```swift\n\u002F\u002F WRONG — service UUID not in NSAccessorySetupBluetoothServices\nvar descriptor = ASDiscoveryDescriptor()\ndescriptor.bluetoothServiceUUID = CBUUID(string: \"UNDECLARED-UUID\")\nsession.showPicker(for: [item]) { _ in }  \u002F\u002F Crash\n\n\u002F\u002F CORRECT — declare all UUIDs in Info.plist first\n\u002F\u002F Info.plist: NSAccessorySetupBluetoothServices = [\"ABCD1234-...\"]\nvar descriptor = ASDiscoveryDescriptor()\ndescriptor.bluetoothServiceUUID = CBUUID(string: \"ABCD1234-...\")\n```\n\n### DON'T: Set both ssid and ssidPrefix\n\n```swift\n\u002F\u002F WRONG — crashes at runtime\nvar descriptor = ASDiscoveryDescriptor()\ndescriptor.ssid = \"MyNetwork\"\ndescriptor.ssidPrefix = \"My\"  \u002F\u002F Cannot set both\n\n\u002F\u002F CORRECT — use one or the other\nvar descriptor = ASDiscoveryDescriptor()\ndescriptor.ssid = \"MyNetwork\"\n```\n\n### DON'T: Initialize CBCentralManager before migration\n\n```swift\n\u002F\u002F WRONG — migration fails, picker does not appear\nlet central = CBCentralManager(delegate: self, queue: nil)\nsession.showPicker(for: [migrationItem]) { error in\n    \u002F\u002F error is non-nil\n}\n\n\u002F\u002F CORRECT — wait for .migrationComplete before using CoreBluetooth\nsession.activate(on: .main) { event in\n    if event.eventType == .migrationComplete {\n        let central = CBCentralManager(delegate: self, queue: nil)\n    }\n}\n```\n\n### DON'T: Show the picker without user intent\n\n```swift\n\u002F\u002F WRONG — picker appears unexpectedly on app launch\noverride func viewDidLoad() {\n    super.viewDidLoad()\n    session.showPicker(for: items) { _ in }\n}\n\n\u002F\u002F CORRECT — bind picker to a user action\n@IBAction func addAccessoryTapped(_ sender: UIButton) {\n    session.showPicker(for: items) { _ in }\n}\n```\n\n### DON'T: Reuse an invalidated session\n\n```swift\n\u002F\u002F WRONG — session is dead after invalidation\nsession.showPicker(for: items) { _ in }  \u002F\u002F No effect\n\n\u002F\u002F CORRECT — create a new session\nlet newSession = ASAccessorySession()\nnewSession.activate(on: .main) { event in\n    \u002F\u002F Handle events\n}\n```\n\n## Review Checklist\n\n- [ ] `NSAccessorySetupSupports` added to Info.plist with `Bluetooth` and\u002For `WiFi`\n- [ ] Bluetooth-specific plist keys (`NSAccessorySetupBluetoothServices`, `NSAccessorySetupBluetoothNames`, `NSAccessorySetupBluetoothCompanyIdentifiers`) match descriptor values\n- [ ] Session activated before calling `showPicker`\n- [ ] Event handler uses `[weak self]` to avoid retain cycles\n- [ ] All `ASAccessoryEventType` cases handled, including `@unknown default`\n- [ ] Product images use transparent backgrounds and appropriate resolution\n- [ ] `ssid` and `ssidPrefix` are never set simultaneously on a descriptor\n- [ ] Picker presentation tied to explicit user action, not automatic\n- [ ] `CBCentralManager` not initialized until after migration completes (if migrating)\n- [ ] `bluetoothIdentifier` or `ssid` from `ASAccessory` used to connect post-setup\n- [ ] Invalidated sessions replaced with new instances\n- [ ] Accessory removal events handled to clean up app state\n\n## References\n\n- Extended patterns (custom filtering, batch setup, removal handling, error recovery): [references\u002Faccessorysetupkit-patterns.md](references\u002Faccessorysetupkit-patterns.md)\n- [AccessorySetupKit framework](https:\u002F\u002Fsosumi.ai\u002Fdocumentation\u002Faccessorysetupkit)\n- [ASAccessorySession](https:\u002F\u002Fsosumi.ai\u002Fdocumentation\u002Faccessorysetupkit\u002Fasaccessorysession)\n- [ASDiscoveryDescriptor](https:\u002F\u002Fsosumi.ai\u002Fdocumentation\u002Faccessorysetupkit\u002Fasdiscoverydescriptor)\n- [ASPickerDisplayItem](https:\u002F\u002Fsosumi.ai\u002Fdocumentation\u002Faccessorysetupkit\u002Faspickerdisplayitem)\n- [ASAccessory](https:\u002F\u002Fsosumi.ai\u002Fdocumentation\u002Faccessorysetupkit\u002Fasaccessory)\n- [ASAccessoryEvent](https:\u002F\u002Fsosumi.ai\u002Fdocumentation\u002Faccessorysetupkit\u002Fasaccessoryevent)\n- [ASMigrationDisplayItem](https:\u002F\u002Fsosumi.ai\u002Fdocumentation\u002Faccessorysetupkit\u002Fasmigrationdisplayitem)\n- [Discovering and configuring accessories](https:\u002F\u002Fsosumi.ai\u002Fdocumentation\u002Faccessorysetupkit\u002Fdiscovering-and-configuring-accessories)\n- [Setting up and authorizing a Bluetooth accessory](https:\u002F\u002Fsosumi.ai\u002Fdocumentation\u002Faccessorysetupkit\u002Fsetting-up-and-authorizing-a-bluetooth-accessory)\n- [Meet AccessorySetupKit — WWDC24](https:\u002F\u002Fsosumi.ai\u002Fvideos\u002Fplay\u002Fwwdc2024\u002F10203\u002F)\n",{"name":5,"description":7},"master","4aa004da461d820f4ea5499e58eb8d196cf99016","community\u002Fskills_sh\u002Fs\u002Fskills-sh_dpearson2699_swift-ios-skills_accessorysetupkit",0,"https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge","https:\u002F\u002Fskill-explorer-rho.vercel.app","https:\u002F\u002Fgithub.com\u002FLord1Egypt","Unbreakable. Unstoppable. Unmatched⚡.\r\n Speaker of machine tongues 🤖  | World-builder of decentralized dreams 🌐 | Defender of the digital realm🛡️.","2026-06-10 08:21:01",{"source":8,"skillName":5,"commands":34,"prompt":44,"zipAvailable":45},[35,38,41],{"tool":36,"command":37},"npx","npx skills add Lord1Egypt\u002Fawesome-skill-forge --skill accessorysetupkit",{"tool":39,"command":40},"bunx","bunx skills add Lord1Egypt\u002Fawesome-skill-forge --skill accessorysetupkit",{"tool":42,"command":43},"pnpm","pnpm dlx skills add Lord1Egypt\u002Fawesome-skill-forge --skill accessorysetupkit","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fcommunity\u002Fskills_sh\u002Fs\u002Fskills-sh_dpearson2699_swift-ios-skills_accessorysetupkit\u002FSKILL.md",true,[],[48,55,62,69,76,83],{"skillNo":49,"name":50,"nameZh":6,"description":51,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":52,"categories":53,"keywords":54,"publishedAt":19},"01M785WKJB99G3STR1NF9NRTJW","youtube-content","YouTube transcripts to summaries, threads, blogs.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Fyoutube-content\u002FSKILL.md",[],[],{"skillNo":56,"name":57,"nameZh":6,"description":58,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":59,"categories":60,"keywords":61,"publishedAt":19},"01M785WEFHB0G2S9YA6EPR3H0E","xurl","X\u002FTwitter via xurl CLI: post, search, DM, media, v2 API.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Fxurl\u002FSKILL.md",[],[],{"skillNo":63,"name":64,"nameZh":6,"description":65,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":66,"categories":67,"keywords":68,"publishedAt":19},"01M785W98EDN4EFJXJPMQEHCRC","touchdesigner-mcp","Control a running TouchDesigner instance via twozero MCP — create operators, set parameters, wire connections, execute Python, build real-time visuals. 36 native tools.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Ftouchdesigner-mcp\u002FSKILL.md",[],[],{"skillNo":70,"name":71,"nameZh":6,"description":72,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":73,"categories":74,"keywords":75,"publishedAt":19},"01M785W5S9FP3QBH2V191E025P","test-driven-development","TDD: enforce RED-GREEN-REFACTOR, tests before code.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Ftest-driven-development\u002FSKILL.md",[],[],{"skillNo":77,"name":78,"nameZh":6,"description":79,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":80,"categories":81,"keywords":82,"publishedAt":19},"01M785W2AS08NSSH9YATCV6FJB","teams-meeting-pipeline","Operate the Teams meeting summary pipeline via Hermes CLI — summarize meetings, inspect pipeline status, replay jobs, manage Microsoft Graph subscriptions.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Fteams-meeting-pipeline\u002FSKILL.md",[],[],{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":19},"01M785VXKW4T34BTP1SCHW1R7F","systematic-debugging","4-phase root cause debugging: understand bugs before fixing.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Fsystematic-debugging\u002FSKILL.md",[],[]]