cannot find type 'FilePath' in scope

I copied and pasted the example code snippet of https://developer.apple.com/documentation/System/FilePath into XCode Playground

let message: String = "This is a log message."
let path: FilePath = "/tmp/log"
let fd = try FileDescriptor.open(path, .writeOnly, options: .append)
try fd.closeAfter { try fd.writeAll(message.utf8) }

The run complains that

expression failed to parse:
error: MyPlayground.playground:2:11: error: cannot find type 'FilePath' in scope
let path: FilePath = "/tmp/log"
     ^~~~~~~~

error: MyPlayground.playground:3:14: error: cannot find 'FileDescriptor' in scope
let fd = try FileDescriptor.open(path, .writeOnly, options: .append)
       ^~~~~~~~~~~~~~

I use macOS 13.0.1 (22A400) and XCode 14.1 (14B47b). The above document link tells macOS 11.0+. It seems I am using a sufficiently new environment that should have FilePath, right?

Answered by darkpaw in 737513022

You need to import System at the top of the file.

Accepted Answer

You need to import System at the top of the file.