HomeKit with AI agents
HomeKit lets your app coordinate home automation accessories from multiple vendors through a shared, cross-device home database. Enable the HomeKit capability, add an NSHomeKitUsageDescription purpose string—your app crashes without it—and talk to homes through a single HMHomeManager. Start from Apple’s HomeKit docs, then compare Apple Docs MCP, Sosumi, ApKI and swiftui-pro.
Last updated:
Apple facts are from "HomeKit", "Enabling HomeKit in your app", "Testing your app with the HomeKit Accessory Simulator", "HMHomeManager", "HMHome", "HMAccessory", "HMService", "HMCharacteristic" and "HMActionSet" on developer.apple.com. Tool facts are from each README. Stars as of 26 Nov 2026.
What Apple documents
The HomeKit framework lets your app configure, control and communicate with home automation accessories. Apple’s overview says you use it to coordinate accessories from multiple vendors into a coherent, user-focused interface: discover HomeKit-compatible accessories and add them to a persistent, cross-device home configuration database; display, edit and act upon that data; and communicate with configured accessories and services to perform actions like turning on the lights in the living room. It is documented for iOS 8, iPadOS 8, Mac Catalyst 14, tvOS 10, visionOS 1 and watchOS 2.
Enabling HomeKit in your app says you enable the HomeKit capability in Xcode’s Signing and Capabilities pane. Xcode then adds the
com.apple.developer.homekitentitlement, the corresponding feature to your App ID, and links the HomeKit framework. HomeKit supports independent Apple Watch apps in watchOS 7 and later. The first time the app uses HomeKit—typically when you create anHMHomeManager—the system prompts the user for permission. You must set anNSHomeKitUsageDescriptionpurpose string in the app’s Information Property List; if you omit it, the app crashes on first use. If the user denies access, look for ahomeAccessNotAuthorizederror or inspectauthorizationStatus. The system remembers a grant; the user can later revoke permission in Settings, so handle both cases.HMHomeManageris the manager for a collection of one or more of a user’s homes. HomeKit stores the user’s home automation information in a database shared among Apple’s Home app, your app and other HomeKit apps. Each app creates a single home manager. Thehomesarray gives youHMHomeinstances. AdoptHMHomeManagerDelegateto stay informed of changes made outside your app. AnHMHomeis a top-level container—rooms optionally grouped into zones, plus action sets and triggers. Create a new home only in response to a specific user request, by callingaddHome(withName:completionHandler:)with a name the user supplies; you don’t createHMHomeinstances directly. AdoptHMHomeDelegatefor configuration changes from other apps.You don’t create
HMAccessoryinstances yourself. Get them from a home’saccessoriesarray, or from a room. To add accessories, calladdAndSetupAccessories(completionHandler:); HomeKit presents a system interface that searches for accessories, names them and assigns them to a room. An accessory exposes one or moreHMServiceobjects (for example, a garage door opener may have a door service and a light). Each service hasHMCharacteristicvalues you can read or write. AnHMActionSetis a group of actions you trigger withexecuteActionSet(_:completionHandler:); you create one withaddActionSet(withName:completionHandler:). Actions run in an unspecified order.Testing your app with the HomeKit Accessory Simulator says you can install HAS to simulate accessories you don’t have, or to help automate testing. Download it as part of the Additional Tools for Xcode package from the More Downloads for Apple Developers page, matching your Xcode version. Open the disk image, go to the Hardware folder, drag
HomeKitAccessorySimulator.appto Applications, and launch it. You can define accessories with standard or custom services and characteristics, and use the Mac’s camera to simulate network cameras and video doorbells.
Rules for AGENTS.md
Code
- Use HomeKit to coordinate home automation accessories through the shared home configuration database. Enable the HomeKit capability in Xcode and add an NSHomeKitUsageDescription purpose string. Without the purpose string the app crashes on first HomeKit use.
- Create a single HMHomeManager. Read homes from the homes array. Create a new home only after a user request, via addHome(withName:completionHandler:). Do not create HMHome or HMAccessory instances yourself.
- Add accessories with addAndSetupAccessories(completionHandler:) so HomeKit can present the system setup UI. Control features through HMService and HMCharacteristic. Handle homeAccessNotAuthorized and authorizationStatus, including a later revocation in Settings.
- For accessories you do not have, use the HomeKit Accessory Simulator from Additional Tools for Xcode. Do not treat that tool as a general iOS Simulator workflow. Look up Apple's HomeKit docs first.Step 1: ground the agent in Apple's HomeKit docs
Install Apple Docs MCP or Sosumi and ask it to open “HomeKit”, “Enabling HomeKit in your app”, HMHomeManager, HMHome and HMAccessory. Confirm the work is a HomeKit home-automation client, not a CloudKit or general iOS Simulator task.
Step 2: add the capability and the purpose string
Have the agent enable the HomeKit capability and set NSHomeKitUsageDescription before creating HMHomeManager. Do not let it skip the purpose string, or assume a denied or later-revoked grant still allows access.
Step 3: use the home manager and system setup UI
Create one HMHomeManager, read homes, and add accessories only through addAndSetupAccessories(completionHandler:). Control services and characteristics on the accessories the home already contains. Create a new home only when the user asks, with addHome(withName:completionHandler:).
Step 4: review the SwiftUI around the HomeKit flow
Run swiftui-pro on the screens that show homes, rooms and accessory controls. Do not replace HomeKit permission or accessory-setup work with SwiftUI-only advice.
Tools compared (4)
| Tool | Best for | Agents (README) | Install (README) | License | Stars | Last push |
|---|---|---|---|---|---|---|
| Apple Docs MCP (kimsungwhee) | Look up HomeKit capability steps, HMHomeManager, accessories and the purpose string | Claude Code, Cursor, VS Code, Windsurf | claude mcp add apple-docs -- npx -y @kimsungwhee/apple-docs-mcp@latest | MIT | 1390 | 17 Mar 2026 ⚠ |
| sosumi.ai (NSHipster) | Pull HomeKit docs as Markdown | any MCP host | npx -y mcp-remote https://sosumi.ai/mcp | MIT | 498 | 25 Nov 2026 |
| ApKI (Gucky) | Route the agent to official Apple developer resources | Codex, Claude Code | npx skills add https://github.com/Gucky/ApKI --skill apki | MIT | 2 | 3 Nov 2026 |
| swiftui-pro (twostraws) | Modern SwiftUI around the screens that show homes and accessories | Claude Code, Cursor, Codex, Gemini | npx skills add https://github.com/twostraws/SwiftUI-Agent-Skill --skill swiftui-pro | MIT | 6633 | 26 Oct 2026 |
⚠ = no push in the last 4 weeks.
Which one to pick
Official API lookup → Apple Docs MCP or Sosumi.
A short route into Apple's current developer resources → ApKI.
SwiftUI around the screens that show homes and accessories → swiftui-pro.
A prompt that keeps the agent honest
Code
Add HomeKit support to this existing iOS app. Enable the HomeKit capability in Xcode and set an NSHomeKitUsageDescription purpose string before creating HMHomeManager; the app crashes on first use without that string. Use a single HMHomeManager and read homes from the homes array. Create a new home only when the user asks, with addHome(withName:completionHandler:). Add accessories through addAndSetupAccessories(completionHandler:) so HomeKit can present the system setup UI. Control features through HMService and HMCharacteristic, and handle homeAccessNotAuthorized plus a later revocation in Settings. For accessories we do not have, use the HomeKit Accessory Simulator from Additional Tools for Xcode, not a general iOS Simulator workflow. Look up “HomeKit”, “Enabling HomeKit in your app”, HMHomeManager, HMHome and HMAccessory in Apple's docs first.FAQ
- Do I need a HomeKit capability and a purpose string?
- Yes. Apple’s enabling article says you enable the HomeKit capability in Xcode’s Signing and Capabilities pane, which adds the `com.apple.developer.homekit` entitlement, the corresponding App ID feature and the HomeKit framework. You must also set an `NSHomeKitUsageDescription` purpose string in Info.plist. The first time the app uses HomeKit—typically when you create an `HMHomeManager`—the system prompts the user with that string. If you omit the purpose string, the app crashes on first use. If the user denies access, look for a `homeAccessNotAuthorized` error or inspect `authorizationStatus`, and handle both the initial denial and a later revocation in Settings.
- How does HMHomeManager work?
- HomeKit stores the user’s home automation information in a database shared among Apple’s Home app, your app and other HomeKit apps. Each app creates a single `HMHomeManager` to coordinate its HomeKit work. The manager’s `homes` array gives you `HMHome` instances, which contain the accessories your app can inspect and control. Adopt `HMHomeManagerDelegate` to hear about changes made outside your app. Create a new home only in response to a specific user request, by calling `addHome(withName:completionHandler:)` with a name the user supplies; you don’t create `HMHome` instances directly.
- How do I add or control accessories?
- You don’t create `HMAccessory` instances yourself. Get them from a home’s `accessories` array, or from a room’s array. To add new accessories, call the home’s `addAndSetupAccessories(completionHandler:)` method; HomeKit then presents a system interface that searches for accessories, names them and assigns them to a room. An accessory exposes one or more `HMService` objects—for example a garage door opener may have a door service and a light service—and each service has `HMCharacteristic` values you can read or write. Trigger a group of actions with an `HMActionSet` via `executeActionSet(_:completionHandler:)`.
- How can I test without physical accessories?
- Apple’s testing article says you can install the HomeKit Accessory Simulator to simulate accessories you don’t have, or to help automate testing. You download it as part of the Additional Tools for Xcode package from the More Downloads for Apple Developers page, choosing the package that matches your Xcode version. After opening the disk image, go to the Hardware folder, drag HomeKitAccessorySimulator.app to Applications, and launch it. In the simulator you define accessories with standard or custom services and characteristics; you can also use the Mac’s camera to simulate network cameras and video doorbells.
- Which tools should the agent use first?
- Start with Apple Docs MCP or Sosumi so the agent opens HomeKit, Enabling HomeKit in your app, HMHomeManager, HMHome and HMAccessory instead of inventing a custom accessory protocol or skipping the purpose string. Use ApKI if the agent needs a short route into current official Apple developer resources. Use swiftui-pro only for the SwiftUI screens around the HomeKit flow, not as a substitute for HomeKit setup.