xcrun simctl io recordvideo fails when executed from Mac App

The execution of the command `xcrun simctl io recordVideo ...` works great from the terminal but fails somehow from the Mac app I'm building:


DN - Local Port: 41227\nCouldn\'t create an asset writer for writing video frames: 
allocationErrorError starting video recorder: 
Error Domain=simctl.SimulatorError Code=2 \"We could not allocate necessary AV objects to perform the recording.\"


I've tried setting permissions like screen recording, Developer Tools but without luck. Also, Sandbox enabled/disabled didn't make a difference.


Any idea?