Spend few days around iOS developers and you will certainly hear at least one (probably more) of them rolling his/hers eyes when Xcode binary signing and provisioning profiles are mentioned. For several years I usually resolved any issues quickly and as it happens – when it hit me as it has others, I was on the edge of throwing my MBP out of the window.
This afternoon I was packaging Run 5k and Go Couch to 5k builds for submission. I wanted to completely separate the apps thus was setting up various parameters so they work properly even in case both are installed on the same device. Highly unlikely for anyone but me, but if it happens it creates pretty serious issues, possibly even data loss.
In the process of fiddling with App Groups, containers and such, at one point I re-generated some profiles on the Developer Portal. When I went to build and submit, this tripped me up:
Like hell. The certificate was identical. I tried anything I could think off, including cleaning the project and/or build folder, derived data, multiple refreshes of the profiles. I even deleted entire local storage of profiles and re-downloaded all of them – nothing helped.
This particular case proves what I suspect is the general cause of signing issues for anyone: you never, ever want to manually fiddle with profiles that Xcode has created or touched in any way. Even if - on the surface - you don’t change anything significant but simply re-save something on the Portal, chances are you have altered something inside the profile that Xcode checks for, but failing that check is not exposed as proper error message in Xcode and it falls through to this more general message above.
The only solution here was that I went to Developer Portal, removed all profiles, then removed all downloaded profiles through Finder, did Clean project and Clean Build folder, closed and re-opened Xcode.
Then I opened my project, went to both app and extension targets - at which point Xcode realized no profiles are present and thus goes to Developer Portal to get them. Since there’s nothing to download, it goes through each App ID you have on your account and creates development profile for each one.
Remember: you don’t do anything! Just let it work and wait a bit until all the “Fix issues” are gone, as it does its work. I was simply switching between the targets to force display refresh until all was fine. Then Build the project; at this point it should complete successfully.
Ok one last step: archive the build, then go to submit it. Xcode will first complain that it could not find proper distribution profile - again do not attempt to do anything manually. While Xcode was displaying you this message, it has also fired off a background process to create distribution profile on the Portal.
Thus simply click “Try again” button and voila – magic.
It works just as it does in WWDC sessions. :)