App Sandbox blocked my launchPath

I need help, when I run code without a sandbox it works well. however, when I enabled it, it gave me (Thread 3: "launch path not accessible")! How can I fix that?

let task = Process()

        task.launchPath = "/Users/alielzieny/Documents/TerrierSectraFix/TerrierSectraFix/Frameworks/python3"
        task.arguments = ["/Users/alielzieny/Documents/TerrierSectraFix/TerrierSectraFix/SectraFix.py", selectedDirectoryURL.path, destinationDirectoryURL.path]
        
        let pipe = Pipe()
        task.standardOutput = pipe
        
        task.launch()
        task.waitUntilExit()
        
        let data = pipe.fileHandleForReading.readDataToEndOfFile()
        if let output = String(data: data, encoding: .utf8) {
            print(output)
        }

There isn’t a good way to do this. Check out On File System Permissions, and specifically the note that starts “There’s currently no way to get a dynamic sandbox extension that grants executable access.”

The next step depends on whether you want to ship in the Mac App Store or not:

  • If you do, then sandboxing is mandatory. If you need to run Python code, standard practice is to embed the Python runtime within your app. You then either launch the python3 executable as a child process or link to the Python runtime and call it to run your code.

  • If you’re distributing directly, you have the option to ship without sandboxing enabled.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

App Sandbox blocked my launchPath
 
 
Q