Isolating Code Signing Problems from Build Problems

This thread has been locked by a moderator.

I regularly see folks having problems where their app works fine when they run it from Xcode but crashes when they release it. There are various potential causes for this. If you want to learn more, check out Testing a release build. This post, however, goes into depth on the first step, isolating code signing problems from build problems.

If you have questions or comments, please start a new thread and tag it with Debugging so that I see it.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"


Isolating Code Signing Problems from Build Problems

When you go to distribute your app from the Xcode organiser, it may behave differently than the version you get when you run the app using Product > Run. This is tricky because the standard distribution workflow changes two factors:

  • It uses the Release build configuration, as opposed to the Debug build configuration you get when you choose Product > Run.

  • It applies Distribution code signing, as opposed to the Development code signing you get when you choose Product > Run.

Before trying to debug a problem like this, it’s important that you isolate the factor that’s causing it.

IMPORTANT This post assumes that you’re testing your Distribution-signed product in a supported fashion. For App Store apps that means testing with TestFlight. See Don’t Run App Store Distribution-Signed Code.

Note This post is aimed at folks using Xcode to build apps. If you not using Xcode, or using Xcode to build something other than an app, the specific techniques discussed here won’t work, but it’s likely that you can adapt them to your circumstances. It also assumes your project is set up in the normal way, with two build configurations, Debug and Release, and Signing & Capabilities set to use Development signing.

To isolate these factors:

  1. Open the Xcode organiser.

  2. Select the archive of the app that’s having problems.

  3. Click Distribute App.

  4. Select Development.

  5. Continue with the distribution workflow.

When you’re done you’ll end up with one of two things:

  • For macOS, an app that you can launch directly from the Finder

  • For iOS, or one of its child platforms, a .ipa file

In the second case, install that .ipa file on your test device:

  1. Connect the device using USB.

  2. In the Finder, open a new window by choosing File > New Finder Window.

  3. On the left, select your device.

  4. Drag your .ipa file to that window. The Finder will install the app on the device.

Now run the app and try to reproduce the problem. There are two possible results here:

  • The problem does reproduce. In this case the relevant factor is the build configuration because you’ve kept that constant while varying the signing.

  • The problem does not reproduce. In this case the relevant factor is the code signing because that’s what you varied.

My experience is that the vast majority of problems like this fall into the first group. If that’s what you see, the next step is to change the build configuration used by Product > Run. To do this:

  1. In Xcode, choose Product > Scheme > Edit Scheme.

  2. On the left, select Run.

  3. In the middle, select the Info tab.

  4. Change the Build Configuration popup to Release.

Now run the app using Product > Run. That should reproduce the problem and you can debug from there.

IMPORTANT The Release build configuration typically enables compiler optimisations that result in a very poor debugging experience. However, it’s likely that you can still make progress. If necessary, add debugging print statements to your code to help you isolate issues.

Don’t forget to change the Build Configuration back to Debug when you’re done.

ps Well done Claude31! for managing to add a comment in the seconds it took me to lock the thread (-:

Up vote post of eskimo
960 views
  • we shall wait, …😉

Add a Comment