When running a unit test target needing an entitlement (keychain access) it does not work out of the box on Xcode. You get some descriptive error in the console about a "missing entitlement". Everything works fine on the Simulator though.
Often this is a case of the executable bundle's code signature not begin valid anymore because a testing bundle was added/linked to the executable before deployment to the device. Easiest fix is to add a new "Run Script Build Phase" with the content:
Now try (cleaning and) running your unit tests again. Good chance it now works.
codesign --verify --force --sign "$CODE_SIGN_IDENTITY" "$CODESIGNING_FOLDER_PATH"
Now try (cleaning and) running your unit tests again. Good chance it now works.Written by

Jeroen Leenarts
Our Ideas
Explore More Blogs


The Unwritten Playbook: Leading Without a Title
The Unwritten Playbook: Leading Without a Title Leading Without a Title: The Consultant’s Guide to Stealth Influence “Why should we listen...
Jethro Sloan


The Unwritten Playbook: Winning as a Team
The Unwritten Playbook: Winning as a Team Team Whispering: Navigating the Human Dynamics No One Prepared You For "We’ve gone through three...
Jethro Sloan

