
accessorysetupkit
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.
- Installs
- 3.1K
- Last 24h
- +15
- Trending rank
- #7108
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/dpearson2699/swift-ios-skills --skill accessorysetupkit- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads accessorysetupkit automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
AccessorySetupKit
Use the iOS 18+ system picker for privacy-preserving Bluetooth/Wi-Fi accessory discovery and authorization, then hand off communication to CoreBluetooth or NetworkExtension.
Contents
- Setup and Entitlements
- Discovery Descriptors
- Presenting the Picker
- Event Handling
- Bluetooth Accessories
- Wi-Fi Accessories
- Migration from CoreBluetooth
- Common Mistakes
- Review Checklist
- References
Setup and Entitlements
Info.plist Configuration
Add these keys to the app's Info.plist:
| Key | Type | Purpose |
|---|---|---|
NSAccessorySetupSupports | [String] | Required. Array containing Bluetooth and/or WiFi |
NSAccessorySetupBluetoothServices | [String] | Service UUIDs the app discovers (Bluetooth) |
NSAccessorySetupBluetoothNames | [String] | Bluetooth names or substrings to match |
NSAccessorySetupBluetoothCompanyIdentifiers | [String] | Two-byte Bluetooth company identifiers |
The Bluetooth-specific keys must match the values used in ASDiscoveryDescriptor.
If the app uses identifiers, names, or services not declared in Info.plist, the
app crashes during AccessorySetupKit discovery. For Wi-Fi accessories, include
WiFi in NSAccessorySetupSupports and match the descriptor's SSID rule.
No Bluetooth Permission Required
When an app declares NSAccessorySetupSupports with Bluetooth, creating a
CBCentralManager no longer triggers the system Bluetooth permission dialog.
The central manager's state transitions to poweredOn only when the app has
at least one paired accessory via AccessorySetupKit.
Discovery Descriptors
ASDiscoveryDescriptor defines the matching criteria for finding accessories.
The system matches scanned results against all rules in the descriptor to
filter for the target accessory.
Bluetooth Descriptor
import AccessorySetupKit
import CoreBluetooth
var descriptor = ASDiscoveryDescriptor()
descriptor.bluetoothServiceUUID = CBUUID(string: "12345678-1234-1234-1234-123456789ABC")
descriptor.bluetoothNameSubstring = "MyDevice"
descriptor.bluetoothRange = .immediate // Only nearby devices
A Bluetooth descriptor needs at least one of bluetoothCompanyIdentifier or
bluetoothServiceUUID. Add narrower matchers as needed:
bluetoothNameSubstringwith a company identifier or service UUIDbluetoothManufacturerDataBlobandbluetoothManufacturerDataMaskwith a company identifier; blob and mask must have the same lengthbluetoothServiceDataBlobandbluetoothServiceDataMaskwith a service UUID; blob and mask must have the same length
Wi-Fi Descriptor
var descriptor = ASDiscoveryDescriptor()
descriptor.ssid = "MyAccessory-Network"
// OR use a prefix:
// descriptor.ssidPrefix = "MyAccessory-"
Supply either ssid or ssidPrefix, not both. The app crashes if both are set.
The ssidPrefix must have a non-zero length.
Bluetooth Range
Control the physical proximity required for discovery:
| Value | Behavior |
|---|---|
.default | Standard Bluetooth range |
.immediate | Only accessories in close physical proximity |
Support Options
Set supportedOptions on the descriptor to declare the accessory's capabilities:
descriptor.supportedOptions = [.bluetoothPairingLE, .bluetoothTransportBridging]
| Option | Purpose |
|---|---|
.bluetoothPairingLE | BLE pairing support |
.bluetoothTransportBridging | Bluetooth transport bridging |
.bluetoothHID | Bluetooth HID device |
Presenting the Picker
Creating the Session
Create and activate an ASAccessorySession to manage discovery lifecycle. Wait for .activated before reading session.accessories or presenting the picker:
import AccessorySetupKit
final class AccessoryManager {
private let session = ASAccessorySession()
func start() {
session.activate(on: .main) { [weak self] event in
self?.handleEvent(event)
}
}
private func handleEvent(_ event: ASAccessoryEvent) {
switch event.eventType {
case .activated:
// Session ready. Check session.accessories for previously paired devices.
break
case .accessoryAdded:
guard let accessory = event.accessory else { return }
handleAccessoryAdded(accessory)
case .accessoryChanged:
// Accessory properties changed (e.g., display name updated in Settings)
break
case .accessoryRemoved:
// Accessory removed by user or app
break
case .invalidated:
// Session invalidated, cannot be reused
break
@unknown default:
break
}
}
}
Showing the Picker
Create ASPickerDisplayItem instances with a name, product image, and
discovery descriptor, then pass them to the activated session:
func showAccessoryPicker() {
var descriptor = ASDiscoveryDescriptor()
descriptor.bluetoothServiceUUID = CBUUID(string: "ABCD1234-0000-1000-8000-00805F9B34FB")
guard let image = UIImage(named: "my-accessory") else { return }
let item = ASPickerDisplayItem(
name: "My Bluetooth Accessory",
productImage: image,
descriptor: descriptor
)
session.showPicker(for: [item]) { error in
if let error {
print("Picker failed: \(error.localizedDescription)")
}
}
}
The picker runs in a separate system process. It shows each matching device as a separate item. When multiple devices match a given descriptor, the picker creates a horizontal carousel.
Setup Options
Configure picker behavior per display item:
var item = ASPickerDisplayItem(
name: "My Accessory",
productImage: image,
descriptor: descriptor
)
item.setupOptions = [.rename, .confirmAuthorization]
| Option | Effect |
|---|---|
.rename | Allow renaming the accessory during setup |
.confirmAuthorization | Show authorization confirmation before setup |
.finishInApp | Signal that setup continues in the app after pairing |
Product Images
The picker displays images in a 180x120 point container. Best practices:
- Use high-resolution images for all screen scale factors
- Use transparent backgrounds for correct light/dark mode appearance
- Adjust transparent borders as padding to control apparent accessory size
- Test in both light and dark mode
Event Handling
Event Types
The session delivers ASAccessoryEvent objects through the event handler:
| Event | When |
|---|---|
.activated | Session is active, query session.accessories |
.accessoryAdded | User selected an accessory in the picker |
.accessoryChanged | Accessory properties updated (e.g., renamed) |
.accessoryRemoved | Accessory removed from system |
.invalidated | Session invalidated, create a new one |
.migrationComplete | Migration of legacy accessories completed |
.pickerDidPresent | Picker appeared on screen |
.pickerDidDismiss | Picker dismissed |
.pickerSetupBridging | Transport bridging setup in progress |
.pickerSetupPairing | Bluetooth pairing in progress |
.pickerSetupFailed | Setup failed |
.pickerSetupRename | User is renaming the accessory |
.accessoryDiscovered | New accessory found (custom filtering mode) |
Coordinating Picker Dismissal
When the user selects an accessory, .accessoryAdded fires before
.pickerDidDismiss. To show custom setup UI after the picker closes, store the
accessory on the first event and act on it after dismissal:
private var pendingAccessory: ASAccessory?
private func handleEvent(_ event: ASAccessoryEvent) {
switch event.eventType {
case .accessoryAdded:
pendingAccessory = event.accessory
case .pickerDidDismiss:
if let accessory = pendingAccessory {
pendingAccessory = nil
beginCustomSetup(accessory)
}
@unknown default:
break
}
}
Bluetooth Accessories
After an accessory is added via the picker, use CoreBluetooth to communicate.
The bluetoothIdentifier on the ASAccessory maps to a CBPeripheral.
import CoreBluetooth
func handleAccessoryAdded(_ accessory: ASAccessory) {
guard let btIdentifier = accessory.bluetoothIdentifier else { return }
// Create CBCentralManager — no Bluetooth permission prompt appears
let centralManager = CBCentralManager(delegate: self, queue: nil)
// After poweredOn, retrieve the peripheral
let peripherals = centralManager.retrievePeripherals(
withIdentifiers: [btIdentifier]
)
guard let peripheral = peripherals.first else { return }
centralManager.connect(peripheral, options: nil)
}
Key points:
CBCentralManagerstate reaches.poweredOnonly when the app has paired accessories- Scanning with
scanForPeripherals(withServices:)returns only accessories paired through AccessorySetupKit - No
NSBluetoothAlwaysUsageDescriptionis needed when using AccessorySetupKit exclusively
Wi-Fi Accessories
For Wi-Fi accessories, the ssid on the ASAccessory identifies the network.
Use NEHotspotConfiguration from NetworkExtension to join it:
import NetworkExtension
func handleWiFiAccessoryAdded(_ accessory: ASAccessory) {
guard let ssid = accessory.ssid else { return }
let configuration = NEHotspotConfiguration(ssid: ssid)
NEHotspotConfigurationManager.shared.apply(configuration) { error in
if let error {
print("Wi-Fi join failed: \(error.localizedDescription)")
}
}
}
Because the accessory was discovered through AccessorySetupKit, joining the network does not trigger the standard Wi-Fi access prompt.
Migration from CoreBluetooth
Apps with existing CoreBluetooth-authorized accessories can migrate them to
AccessorySetupKit using ASMigrationDisplayItem. This is a one-time operation
that registers known accessories in the new system.
func migrateExistingAccessories() {
guard let image = UIImage(named: "my-accessory") else { return }
var descriptor = ASDiscoveryDescriptor()
descriptor.bluetoothServiceUUID = CBUUID(string: "ABCD1234-0000-1000-8000-00805F9B34FB")
let migrationItem = ASMigrationDisplayItem(
name: "My Accessory",
productImage: image,
descriptor: descriptor
)
// Set the peripheral identifier from CoreBluetooth
migrationItem.peripheralIdentifier = existingPeripheralUUID
// For Wi-Fi accessories:
// migrationItem.hotspotSSID = "MyAccessory-WiFi"
session.showPicker(for: [migrationItem]) { error in
if let error {
print("Migration failed: \(error.localizedDescription)")
}
}
}
Migration rules:
- If
showPickercontains only migration items, the system shows an informational page instead of a discovery picker - If migration items are mixed with regular display items, migration happens only when a new accessory is discovered and set up
- Do not initialize
CBCentralManagerbefore migration completes — doing so causes an error and the picker fails to appear - The session receives
.migrationCompletewhen migration finishes
Common Mistakes
| Mistake | Fix |
|---|---|
| Descriptor identifiers are absent from Info.plist | Declare every Bluetooth service, name, and company identifier before presenting the picker. |
Both ssid and ssidPrefix are set | Choose exactly one matching strategy. |
| CoreBluetooth starts before migration completes | Wait for .migrationComplete, then create CBCentralManager. |
| Picker appears without explicit user intent | Present it only from a user action. |
| An invalidated session is reused | Create, activate, and retain a new ASAccessorySession. |
Review Checklist
-
NSAccessorySetupSupportsadded to Info.plist withBluetoothand/orWiFi - Session activated before calling
showPicker - Event handler uses
[weak self]to avoid retain cycles - All
ASAccessoryEventTypecases handled, including@unknown default - Product images use transparent backgrounds and appropriate resolution
-
bluetoothIdentifierorssidfromASAccessoryused to connect post-setup - Accessory removal events handled to clean up app state
References
- Extended patterns (custom filtering, batch setup, removal handling, error recovery): references/accessorysetupkit-patterns.md
- AccessorySetupKit framework
- ASAccessorySession
- ASDiscoveryDescriptor
- ASPickerDisplayItem
- ASAccessory
- ASAccessoryEvent
- ASMigrationDisplayItem
- Discovering and configuring accessories
- Setting up and authorizing a Bluetooth accessory
- Meet AccessorySetupKit — WWDC24
FAQ
What does the accessorysetupkit skill do?
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.
How do I install accessorysetupkit?
Run npx skills add https://github.com/dpearson2699/swift-ios-skills --skill accessorysetupkit in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/accessorysetupkit/ (personal) or .claude/skills/accessorysetupkit/ (project).
Which AI agents can use accessorysetupkit?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is accessorysetupkit safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains accessorysetupkit?
It is published by dpearson2699 in dpearson2699/swift-ios-skills. It has 3,081 recorded installs.
More from dpearson2699/swift-ios-skills
swiftui-animation
dpearson2699/swift-ios-skills
Implement, diagnose, or review SwiftUI motion using explicit and scoped implicit animations, springs, transitions, PhaseAnimator, KeyframeAnimator, matched geometry or navigation zoom, SF Symbol effects, and custom Animation types. Use when views should animate on state changes, insertion, removal, navigation, or multi-step choreography, or when motion must respect Reduce Motion and Swift concurrency.
ios-accessibility
dpearson2699/swift-ios-skills
Build and audit SwiftUI, UIKit, and AppKit accessibility for VoiceOver, Voice Control, Switch Control, Full Keyboard Access, Dynamic Type, focus restoration, labels/traits/actions, traversal, custom rotors, NSAccessibility, XCTest checks, adaptive system preferences, and App Store accessibility declarations. Use when implementing accessible UI, fixing an accessibility audit, testing assistive-technology behavior, or substantiating App Store Accessibility Nutrition Labels.
swiftui-performance
dpearson2699/swift-ios-skills
Profile, diagnose, and remediate SwiftUI runtime performance using code review, Instruments, and repeatable measurements. Use when a SwiftUI screen renders slowly, scrolling or animations hitch, view bodies update excessively, list identity churns, layout work spikes, or broad Observation dependencies raise CPU cost. Covers evidence-based triage, SwiftUI Instruments lanes, lazy-container guardrails, state lifetime, and before/after verification.
swiftui-patterns
dpearson2699/swift-ios-skills
Builds and reviews SwiftUI views with modern MV architecture, state, composition, isolated previews, and migration guidance. Covers @Observable ownership, @State/@Bindable/@Environment wiring, view decomposition, ViewModifiers, environment values, .task loading, iOS 26+ handoffs, Writing Tools, clipboard availability, and performance. Use when structuring SwiftUI state, managing @Observable, composing views, previewing meaningful UI states, or correcting SwiftUI patterns.
app-store-review
dpearson2699/swift-ios-skills
Audits App Store submission readiness and rejection risk across current review guidelines, PrivacyInfo.xcprivacy and required-reason APIs, privacy labels, ATT, StoreKit payments, metadata, entitlements, widgets, and Live Activities. Use when preparing a submission, responding to rejection, reconciling privacy evidence, or separating upload blockers from cleanup.
ios-networking
dpearson2699/swift-ios-skills
Build, review, or improve networking code in iOS/macOS apps using URLSession with async/await, structured concurrency, and modern Swift patterns. Use when working with REST APIs, downloading files, uploading data, WebSocket connections, pagination, retry logic, request middleware, caching, background transfers, or network reachability monitoring. Also use when handling HTTP requests, API clients, network error handling, or data fetching in Swift apps.
Popular mobile skills
design-mobile-apps
designed-by-ai/skills
Design mobile app screens with Sleek, edit Sleek projects, and implement their designs in React Native or HTML.
ios-design
uizze.sh
Design and review iOS UI/UX for iPhone apps in SwiftUI, UIKit, or React Native. Use for mobile app design, screen redesigns, navigation flows, typography, forms, keyboard and safe-area layout, and accessibility checks. Apply Apple Human Interface Guidelines and consult real product references through the optional Uizze connection.
vercel-react-native-skills
vercel-labs/agent-skills
React Native and Expo best practices for building performant mobile apps. Use when building React Native components, optimizing list performance, implementing animations, or working with native modules. Triggers on tasks involving React Native, Expo, mobile performance, or native platform APIs.
animate-expo
emilkowalski/skills
Build animations in React Native and Expo, making the decisions in the order that determines whether they feel right — should it animate, which thread it runs on, which properties, spring or timing, how the gesture hands off, how it degrades. Writes the implementation with Reanimated, Gesture Handler, Expo Router and expo-haptics. Use when animating anything in an Expo app, adding gestures, sheets, screen transitions, press feedback or haptics, or fixing motion that stutters on device. For web animation use animate.
xcode-project-setup
firebase/agent-skills
Safely modifies Xcode projects (.pbxproj) to add Swift Packages and link files. Use this skill whenever an iOS project needs dependencies installed (e.g. Firebase, Alamofire).
firebase-remote-config-basics
firebase/agent-skills
Manages Firebase Remote Config templates, feature flags, loading strategies, and SDKs (Android, iOS). Use when downloading/deploying remoteconfig JSON templates, managing version history/feature flags, setting in-app defaults, fetchAndActivate(), real-time listeners, or SDK setup. Don't use for Firebase Hosting, Auth, Firestore, Data Connect, Crashlytics, or App Hosting.