ProcessException: Operation not permitted

I'm using Flutter for creating app and I need to run a file with arguments from dart code (This file is in the app's container) on MacOS. How can I do it in a sandbox? I don't want to disable sandbox because then i can't publish app in App Store.

I tried this code ProcessResult result = await Process.run(path, [-pa], includeParentEnvironment: true);

but I'm getting error: ProcessException: Operation not permitted.

Also, I saw thing called "Embedding a command-line tool in a sandboxed app", but I don't know how to do it in my case.

Answered by DTS Engineer in 771971022

I need to run a file with arguments

Where is this file located?

If it a native Mach-O executable? Or a script that invokes an intepreter using #!?

Share and Enjoy

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

Accepted Answer

I need to run a file with arguments

Where is this file located?

If it a native Mach-O executable? Or a script that invokes an intepreter using #!?

Share and Enjoy

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

Accidentally marked your answer as a solution...)

When my app is open, it copies from flutter assets an executable file(exiv2) to app's sandboxed container. Then the app opens dialog and asks the folder where a photo is ("com.apple.security.files.user-selected.read-write" key on true), after it I use copied executable file to get metadata from photo but get error Operation not permitted.

Executable file copied in: /Users/execoq/Library/Containers/com.example.geobyphotosFlutter/Data/Library/Application Support/com.example.geobyphotosFlutter/exiv2Mac/bin/exiv2

Photo located in: Volumes/Macintosh HD/Users/execoq/Downloads/Photos/Photos/IMG_8806.jpg

When my app is open, it copies from flutter assets an executable file … to app's sandboxed container.

That’s not going to work. A sandboxed app can’t create a file and run it as an executable [1]. I recommend that you embed this executable in your bundle directly and then run it from there.

Share and Enjoy

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

[1] If it could, there’d be nothing stopping it from downloading non-sandboxed code and running that, which would undermine the sandbox entirely.

I recommend that you embed this executable in your bundle directly

I get it, it makes sense... But do I need to embed the command line to run the embedded executables?

This one: https://developer.apple.com/documentation/xcode/embedding-a-helper-tool-in-a-sandboxed-app

ProcessException: Operation not permitted
 
 
Q