---
title: file()
framework: swift
role: symbol
role_heading: Macro
path: swift/file()
---

# file()

Produces the path to the file in which it appears.

## Declaration

```swift
@freestanding(expression) macro file<T>() -> T where T : ExpressibleByStringLiteral
```

## Overview

Overview The string value from #file depends on the language version, to enable migration from the old #filePath behavior to the new #fileID behavior. Currently, #file has the same value as #filePath. In a future version of Swift, #file will have the same value as #fileID instead. To adopt the future behavior, replace #file with #fileID or #filePath as appropriate. This macro’s value can be changed by #sourceLocation, as described in Line Control Statement in The Swift Programming Language.

## See Also

### Getting Source Location Information

- [fileID()](swift/fileid().md)
- [filePath()](swift/filepath().md)
- [function()](swift/function().md)
- [line()](swift/line().md)
- [column()](swift/column().md)
