Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable sandbox for Xcode UI tests

For my macOS desktop application's UI test target, I need to be able to run command line tools (specifically git) to verify some application actions, but I get an error that it cannot be run in the app sandbox.

I never explicitly enabled sandboxing for either my app or for the test target, so I'm having trouble figuring out how to turn it off. There is no entitlements file, and I can't find any target settings that seem to relate to sandboxing.

So is it possible to disable sandboxing for a UI test target? I know workarounds could include copying git into the bundle, or having the user explicitly select the tool, but neither of those seems really desirable.

Update: I tried copying git into the test bundle to run from there, but still got the same error.

Update 2: You can turn off sandboxing for the test bundle, but the test runner which Xcode builds automatically is still sandboxed (and unable to load an unsigned bundle), and AFAICT there is no way to change how the runner is built. Am I wrong?

like image 509
Uncommon Avatar asked Oct 27 '25 09:10

Uncommon


1 Answers

Create .entitlements file with

<key>com.apple.security.app-sandbox</key> <false/>

and specify CODE_SIGN_ENTITLEMENTS for your UI Tests bundle(via xcconfig or Build Settings -> Signing). Xcode will use value for this entitlement for test runner application.

like image 131
Viktor Radulov Avatar answered Oct 28 '25 23:10

Viktor Radulov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!