---
title: "addService(_:completionHandler:)"
framework: homekit
role: symbol
role_heading: Instance Method
path: "homekit/hmservicegroup/addservice(_:completionhandler:)"
---

# addService(_:completionHandler:)

Adds a new service to the service group.

## Declaration

```swift
func addService(_ service: HMService, completionHandler completion: @escaping @Sendable ((any Error)?) -> Void)
```

```swift
func addService(_ service: HMService) async throws
```

## Parameters

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

## Discussion

Discussion A service can be added to multiple service groups. For example, a light could be added to the “Desk Lamps” service group as well as the “Dimmable Lights” service group.

## See Also

### Managing Service Groups

- [name](homekit/hmservicegroup/name.md)
- [uniqueIdentifier](homekit/hmservicegroup/uniqueidentifier.md)
- [updateName(_:completionHandler:)](homekit/hmservicegroup/updatename(_:completionhandler:).md)
- [services](homekit/hmservicegroup/services.md)
- [removeService(_:completionHandler:)](homekit/hmservicegroup/removeservice(_:completionhandler:).md)
