<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "macOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 9.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "HealthKit",
  "identifier" : "/documentation/HealthKit/HKAttachmentStore/removeAttachment(_:from:completion:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "HealthKit"
    ],
    "preciseIdentifier" : "c:objc(cs)HKAttachmentStore(im)removeAttachment:fromObject:completion:"
  },
  "title" : "removeAttachment(_:from:completion:)"
}
-->

# removeAttachment(_:from:completion:)

Removes the specified attachment.

```
func removeAttachment(_ attachment: HKAttachment, from object: HKObject, completion: @escaping @Sendable (Bool, (any Error)?) -> Void)
```

```
func removeAttachment(_ attachment: HKAttachment, from object: HKObject) async throws
```

## Parameters

`attachment`

An attachment associated with the specified object.

`object`

An object from the HealthKit store.

`completion`

A completion handler that the system calls after removing the attachment. This handler takes the following parameters:

- success: A Boolean value that indicates whether the system successfully removed the attachment.
- error: If an error occurred, this parameter contains information about the error. Otherwise, it’s `nil`.

## Discussion

Use this method to remove an attachment from an object saved in the HealthKit store.

```swift
// Remove the attachment from the specified object.
do {
    try await attachmentStore.removeAttachment(myAttachment, from: myObject)
} catch {
    // Handle the error here.
    fatalError("*** An error occurred while removing an attachment: \(error.localizedDescription) ***")
}
```

---

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)