---
title: "peripheralManager(_:didAdd:error:)"
framework: corebluetooth
role: symbol
role_heading: Instance Method
path: "corebluetooth/cbperipheralmanagerdelegate/peripheralmanager(_:didadd:error:)"
---

# peripheralManager(_:didAdd:error:)

Tells the delegate the peripheral manager published a service to the local GATT database.

## Declaration

```swift
optional func peripheralManager(_ peripheral: CBPeripheralManager, didAdd service: CBService, error: (any Error)?)
```

## Parameters

- `peripheral`: The peripheral manager adding the service.
- `service`: The service added to the local GATT database.
- `error`: The reason the call failed, or nil if no error occurred.

## Discussion

Discussion Core Bluetooth invokes this method when your app calls the add(_:) method to publish a service to the local peripheral’s GATT database. If the service published successfully to the local database, the error parameter is nil. If unsuccessful, the error parameter provides the cause of the failure.
