---
title: "createAudioUnit(with:)"
framework: audiotoolbox
role: symbol
role_heading: Instance Method
path: "audiotoolbox/auaudiounitfactory/createaudiounit(with:)"
---

# createAudioUnit(with:)

Creates an instance of an extension’s audio unit.

## Declaration

```swift
func createAudioUnit(with desc: AudioComponentDescription) throws -> AUAudioUnit
```

## Parameters

- `desc`: The description of the audio component.

## Mentioned in

Rendering Spatial Audio from Bluetooth headphones

## Return Value

Return Value An instance of the extension’s audio unit.

## Discussion

Discussion This method is called only once per factory instance. note: In non-ARC code, “create” methods return unretained objects (unlike C “create” functions). In this scenario, you should return an object with a reference count of 1, but autoreleased. note: In Swift, this method returns a nonoptional result and is marked with the throws keyword to indicate that it throws an error in cases of failure. You call this method in a try expression and handle any errors in the catch clauses of a do statement, as described in Error Handling in The Swift Programming Language and About Imported Cocoa Error Parameters.
