<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 8.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "HomeKit",
  "identifier" : "/documentation/HomeKit/HMServiceGroup/addService(_:completionHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "HomeKit"
    ],
    "preciseIdentifier" : "c:objc(cs)HMServiceGroup(im)addService:completionHandler:"
  },
  "title" : "addService(_:completionHandler:)"
}
-->

# addService(_:completionHandler:)

Adds a new service to the service group.

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

## Parameters

`service`

The service to add.

`completion`

The block executed after the request is processed.

- error: `nil` on success; otherwise, error object indicating the reason for failure.

## 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.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)