<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.5.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AudioToolbox",
  "identifier" : "/documentation/AudioToolbox/AudioFileCreateWithURL(_:_:_:_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Audio Toolbox"
    ],
    "preciseIdentifier" : "c:@F@AudioFileCreateWithURL"
  },
  "title" : "AudioFileCreateWithURL(_:_:_:_:_:)"
}
-->

# AudioFileCreateWithURL(_:_:_:_:_:)

Creates a new audio file, or initializes an existing file, specified by a URL.

```
func AudioFileCreateWithURL(_ inFileRef: CFURL, _ inFileType: AudioFileTypeID, _ inFormat: UnsafePointer<AudioStreamBasicDescription>, _ inFlags: AudioFileFlags, _ outAudioFile: UnsafeMutablePointer<AudioFileID?>) -> OSStatus
```

## Parameters

`inFileRef`

The fully specified path of the file to create or initialize.

`inFileType`

The type of audio file to create.  See [`AudioFileTypeID`](/documentation/AudioToolbox/AudioFileTypeID) for constants that can be used.

`inFormat`

A pointer to the structure that describes the format of the data.

`inFlags`

Relevant flags for creating or opening the file. If [`eraseFile`](/documentation/AudioToolbox/AudioFileFlags/eraseFile) is set, it erases an existing file. If the flag is not set, the function fails fails if the URL is an existing file.

`outAudioFile`

On output, a pointer to a newly created or initialized file.

## Return Value

A result code. See Result Codes.

## Discussion

This function uses a `CFURLRef` type rather than the `FSRef` type used by the deprecated [`AudioFileCreate`](/documentation/AudioToolbox/AudioFileCreate) function.

---

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)