<!--
{
  "availability" : [
    "iOS: 6.0.0 -",
    "iPadOS: 6.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.9.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AVFoundation",
  "identifier" : "/documentation/AVFoundation/AVAssetWriter/finishWriting(completionHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AVFoundation"
    ],
    "preciseIdentifier" : "c:objc(cs)AVAssetWriter(im)finishWritingWithCompletionHandler:"
  },
  "title" : "finishWriting(completionHandler:)"
}
-->

# finishWriting(completionHandler:)

Marks all unfinished inputs as finished and completes the writing of the output file.

```
func finishWriting(completionHandler handler: @escaping @Sendable () -> Void)
```

## Parameters

`handler`

A completion handler the system invokes when it finishes writing. Determine the success or failure of the writing session by querying the asset writer’s [`status`](/documentation/AVFoundation/AVAssetWriter/status-swift.property) property value.

## Discussion

To ensure the asset writer finishes writing all samples, call this method only after all calls to [`append(_:)`](/documentation/AVFoundation/AVAssetWriterInput/append(_:)) or [`append(_:withPresentationTime:)`](/documentation/AVFoundation/AVAssetWriterInputPixelBufferAdaptor/append(_:withPresentationTime:)) return.

---

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)