Cannot find type 'FilePath' in scope

Hi,

Just wondering why I am getting a compilation error

import Foundation

let path: FilePath = "/tmp/log" // Error: Cannot find type 'FilePath' in scope

Error:

Cannot find type 'FilePath' in scope

Note:

  • App minimum version is macOS 26.4 (command line project)
  • macOS 26.5.1 (25F80)
  • Xcode 26.5 (17F42)
  • Swift version 6.3.2

Solution:

  • Sorry found the issue it is defined under System
  • import System // fixes the issue

Confusing / Questions

  • For some strange reason Xcode documentation seemed to list it under Foundation (screenshot below is from Xcode), however opening the same documentation in the web seemed to list it under System
  • What's new in Swift seemed to suggest it is defined in the Standard library, is that correct? I even tried Swift 6.4 and still throws a compilation error

FilePath has just been added to the standard library in Swift 6.4.

I’m not sure why it didn’t work for you; did you use the Xcode 27 beta?

Thanks @snej, not sure if I am missing something.

Yes I had tried on the following environment:

  • Xcode 27.0 beta (27A5194q)
  • macOS 26.5.1 (25F80)
  • Below is the swift version for Xcode-Beta
swift-driver version: 1.167 Apple Swift version 6.4 (swiftlang-6.4.0.20.104 clang-2100.3.20.102)

The proposal has been approved but the implementation hasn't been merged into main yet (let alone the 6.4.x release branch). I imagine it will move forward again once WWDC settles down.

3 Likes

Thanks a lot @allevato for that clarification!

Make sure you've imported the correct module or package that defines FilePath, otherwise the compiler won't recognize the type.