Testflight app crashes only on cellular network

The app works perfectly in debug. However in testflight, when cellular network is enabled, the app randomly crashes just after receiving an api response. The api response provides a text response, in json format. This text response is updated on the screen using a completion handler from the api call. I have tried debugging to the best of my ability, but I can't figure out why (a) the crash is random, (b) only occurs in testflight, and (c) only occurs when cellular network is enabled on the iphone (ios13 -- no crashes when using wifi).
Are you sure this is only on TestFlight? Try taking the Xcode archive that you used to submit to TestFlight, exporting a development build, and installing that on your device.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
Yes, it's only once I've uploaded to testflight. No issues on debug. Not sure what exporting the dev build and installing on device will accomplish? I'll try to do it, if I can figure it out. The crash log from testflight only gives an 'init' error (i guess), seemingly where the first zstack in contentview starts. I tried turning off bit code encoding, but it also did not remove the crashes. The random nature of the crashes, in that it occurs once every 5 - 10 attempts is really strange.

Not sure what exporting the dev build and installing on device will
accomplish?

It ensures that you’re testing exactly the same code as TestFlight is running. When you do a Product > Run, your build differs from the TestFlight build in two ways:
  • It’s Development signed.

  • It’s a Debug build (rather than a Release build).

The former prevents you from attaching with the debugger to see what’s going on. You want to get rid of that restriction. The latter you want to preserve, in that it’s quite common for Debug and Release code to behave differently.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
Is there some step-by-step instructions on how to do this? Because fiddling with XCode I can't seem to find out how, and google hasn't helped (maybe I'm not hitting the right keywords?).

Random frustration: why would deployment build ever be different from debug build? It just seems silly and needlessly convoluted?

why would deployment build ever be different from debug build?

The Release build has optimisations enabled, which is generally considered a good thing, but the Debug build has to disable optimisation to yield a decent debugging experience.

Is there some step-by-step instructions on how to do this?

Are you deploying to App Store Connect via Xcode’s Organizer. If so:
  1. Go to the Organizer.

  2. Select the archive that you used for this TestFlight deployment.

  3. Click Distribute App.

  4. Choose Development (rather than App Store Connect).

  5. Follow the instructions from there.

The end result is a .ipa that you can install on your device using Finder (or Apple Configurator, if you find that easier).

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
Thanks for the explanation. I followed your instructions, using Apple Configurator. The crash still occurred.

I then googled a bit more and decided to try disabling Swift Code optimization for release, in the build settings. It works perfectly now in testflight. Perhaps I do not need optimized code for my app, it seems to work well enough as is.

But now when I got to appstoreconnect, it says: An error has occurred. Try again later.

I can't find my app anymore?

But now when I got to appstoreconnect, it says: An error has occurred.
Try again later.

I can’t help you with App Store Connect issues. If the problem persists, you should open a new thread about that, making sure to apply the App Store Connection tag.

I … decided to try disabling Swift Code optimization for release, in
the build settings. It works perfectly now in testflight.

In the vast majority of cases such problems are caused by an issue in your code rather than an issue with the compiler. Specifically, if you code relies on undefined behaviour, it’s not uncommon for the optimiser to expose that.

I strongly recommend that you investigate and resolve this issue rather than simply ship with optimisations disabled. If you fail to resolve the underlying problem, it may come back at inopportune times.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
I would like to fix this bug. But how can I do so without the ability to debug it? Shipping it now with optimization turned off is a quick way to fix the bug while I try to debug it. Because, I'm not sure exactly how I can debug it? The crash reports are very ambiguous. I don't know if it's possible to simply debug on xcode with the release compiler? I don't even know what the bug is? Or how to find it? All I know is that it has something to do with the optimized compiler. And a single attempt at a debug cycle can easily take 10 minutes instead of 10 seconds.
Testflight app crashes only on cellular network
 
 
Q