---
title: "AudioFileCreateWithURL(_:_:_:_:_:)"
framework: audiotoolbox
role: symbol
role_heading: Function
path: "audiotoolbox/audiofilecreatewithurl(_:_:_:_:_:)"
---

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

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

## Declaration

```swift
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 doc://com.apple.audiotoolbox/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 doc://com.apple.audiotoolbox/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

Return Value A result code. See Result Codes.

## Discussion

Discussion This function uses a CFURLRef type rather than the FSRef type used by the deprecated AudioFileCreate function.

## See Also

### Creating and Initializing Audio Files

- [AudioFileInitializeWithCallbacks(_:_:_:_:_:_:_:_:_:)](audiotoolbox/audiofileinitializewithcallbacks(_:_:_:_:_:_:_:_:_:).md)
