DerivedData on external drive breaks framework tests

Xcode, under Settings → Locations → Derived Data, lets us set a custom DerivedData location (such as on an external drive).

Trying that, I discovered that this breaks the test system for Framework targets (and probably other types of test targets when not hosted in an app target) when the run destination is “My Mac”. This seems to be due to sandboxing (but this is not entirely clear).

Xcode does not provide a warning about this limitation, and does not seem to offer a way to open sandbox access to an external volume(s). Instead, trying to run such tests results in a bunch of error messages in the console log that I did not find helpful in trying to diagnose what went wrong:

Cannot find executable for CFBundle 0x86c47c2a0 </Volumes/external/Xcode/DerivedData/Build/Products/Debug/MyFrameworkTests.xctest> (not loaded)

The bundle “MyFrameworkTests.xctest” couldn’t be loaded because its executable couldn’t be located. Try reinstalling the bundle.

Program ended with exit code: 9

The solutions seem to be either run tests from the command line (to escape sandboxing), or just use the default DerivedData location (and accept its impact on the internal drive’s limited space).

DerivedData on external drive breaks framework tests
 
 
Q