I'm also getting a 513 error no matter what I code. I even tried using chatGTP and Harmony and Copilot generated code. All to no avail.
Here's the copilot code (as it seemed better to me)
func copilotCreateTheNewDirectory(in downloadsURL: URL)
{
guard downloadsURL.startAccessingSecurityScopedResource() else {
let errorMessage = "Failed to access the selected location"
showError = true
return
}
defer {
downloadsURL.stopAccessingSecurityScopedResource()
}
let newDir = "myShinyNewDir"
let fileManager = FileManager.default
let newDirectoryURL = downloadsURL.appendingPathComponent(newDir)
do {
try fileManager.createDirectory(
at: newDirectoryURL,
withIntermediateDirectories: false,
attributes: nil
)
} catch {
let errorMessage = "Failed to create directory: \(error.localizedDescription)"
showError = true
}
}
}
I tried using Swift5 instead of Swift6 and that failed, too.
I tried in Documents and Downloads locations - all failed.
Here are my App Sandbox settings:
Xcode: Version 16.0 (16A242d)
MacOS: Sequoa 15.0.1