---
title: "addAndSetupAccessories(completionHandler:)"
framework: homekit
role: symbol
role_heading: Instance Method
path: "homekit/hmhome/addandsetupaccessories(completionhandler:)"
---

# addAndSetupAccessories(completionHandler:)

Finds and adds nearby accessories to the home.

## Declaration

```swift
func addAndSetupAccessories(completionHandler completion: @escaping @Sendable ((any Error)?) -> Void)
```

```swift
func addAndSetUpAccessories() async throws
```

## Parameters

- `completion`: The block executed after the request is processed.

## Mentioned in

Testing your app with the HomeKit Accessory Simulator

## Discussion

Discussion This method launches an interactive process that first asks the user to provide a HomeKit code for the accessories—for example, by scanning an 8-digit code, by scanning the QR code, wirelessly by holding an iPhone next to the device, or by manually entering the HomeKit code. The process then asks the user to configure the accessory’s services, naming them and placing them in rooms.

## See Also

### Managing accessories

- [accessories](homekit/hmhome/accessories.md)
- [addAndSetupAccessories(with:completionHandler:)](homekit/hmhome/addandsetupaccessories(with:completionhandler:).md)
- [addAccessory(_:completionHandler:)](homekit/hmhome/addaccessory(_:completionhandler:).md)
- [assignAccessory(_:to:completionHandler:)](homekit/hmhome/assignaccessory(_:to:completionhandler:).md)
- [removeAccessory(_:completionHandler:)](homekit/hmhome/removeaccessory(_:completionhandler:).md)
- [supportsAddingNetworkRouter](homekit/hmhome/supportsaddingnetworkrouter.md)
- [unblockAccessory(_:completionHandler:)](homekit/hmhome/unblockaccessory(_:completionhandler:).md)
- [HMAccessory](homekit/hmaccessory.md)
