[Do not duplicate similar questions as described below]
I get a code signing error when starting XCodeBuild from Jenkins, but it will build ok from the command line or from Xcode.
Some people have had this problem in the past, and a common theme with them is that Jenkins starts up at startup as a daemon user and thus tries to access the system keychain. The solutions people use copy credentials into the system keychain or execute a command to determine which gap to use.
However, in my case, if I look at launchd in the Activity Manager, the user appears as the user that I registered on the machine, since Jenkins should work as this user, and not as a daemon user.
I tried to establish which keychain to use by adding this command to the Jenkins script before running XCodeBuild
security list-keychains -s /Users/[user]/Library/Keychains/login.keychain
But this did not solve the problem.
The error I am getting is:
Code Sign error: The identity 'iPhone Developer: NNNNN (9TYX5WAM63)' doesn't match any valid, non-expired certificate/private key pair in your keychains"
So, I tried translating the credentials into the system keychain, but now I get this error in Jenkins, but it is still different from the command line:
Code Sign error: Provisioning profile 'F152C66E-B99A-47F6-B262-376CE4403D71' can't be found
Also, when I transfer credentials to the system keychain, I can no longer build from XCOde - I get the same error as the top error message above.
I also tried editing the org.jenkins-ci.plist file to set the user as the one I registered on the computer, according to this, but this also had no effect.
Lack of certificates and keys in the keychain when using Jenkins / Hudson as a continuous integration for iOS and Mac development
Any ideas what I could try next?