How to overcome entitlement restrictions in framework unit tests in Xcode?

32 Views Asked by At

I have a framework I’m building in Xcode (15.2; Swift 5.9).

I have a unit test target for the framework.

When I try to run the tests, any tests that try to access arbitrary directories or files (I have some sample data folders I am using for the tests) are denied permission.

How can I assign the right “entitlements” (or whatever) so my unit tests can “break out of the sandbox” to read from those files and directories?

An example error message from a failed test:

caught error: "Error Domain=NSCocoaErrorDomain Code=257 "The file “project.pbxproj” couldn’t be opened because you don’t have permission to view it." UserInfo={NSFilePath=/Volumes/user/Projects/XcodeProjectSecurity/TestSamples/TestProject/TestProject.xcodeproj/project.pbxproj, NSUnderlyingError=0x600000c2cfc0 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}}"

0

There are 0 best solutions below