Hit with a code signing fail?

One of the frustrating things about developing for maOS and iOS is code signing. Code signing, to put extremely simply, is a way to make sure that the apps we submit to Apple and the apps you buy from the App Store are legitimate. But sometimes this process can go wrong, or at least seem to go wrong.

I’ve been working on a macOS app for years. Now, I’ve been wanting to get UI Testing to work via Xcode Server. But there was a problem. Code Signing. So, I created a Xcode Bot to build my app and run tests. However, it failed with errors like these:

Error: No profiles for ‘my app’ were found:  Xcode couldn't find any Mac App Development provisioning profiles matching ‘my app’.

and

Error: You are not allowed to perform this operation.  Please check with one of your Team Admins, or, if you need further assistance, please contact Apple Developer Program Support. 

There are not a lot of hits in good on these errors in google, so I dutifully tried and tried to resolve code signing: making sure everything was installed properly on the server and I had all the proper certs and profiles created at Apple. Nothing was working.

Much of the advice I did find on google wasn’t particularly helpful. Solutions, if there was one, ranged from recreating all certs and profiles to reinstalling the OS. None of those sounded like good solutions.

One suggestion that I did follow up on was to look at the more detailed logs for the bot’s attempts. I found some interesting things, such as…

DVTDeveloperAccountManager: Failed to load credentials for …

Grrr!

But I, being slow sometimes (only 46 build attempts via my bot), decided a different approach. How could I get a better handle of what’s wrong? Build the app! I’m sure you’re thinking that I hopefully built the app before I created the bot. Of course I did. But I didn’t build the app on the server itself!

So, I got on the server, checked out the project, built…. build error! I had a build phase that I thought I removed from the project, but it was still there. At this point, I’m not sure how this script wasn’t failing on my other machines, so figuring that out is not on my Kanban board.

The lesson? Code signing errors may be your fault and nothing to do with code signing at all.