How to Debug an Issue with a Release Mode Build in iOS

How do you debug an issue with a release mode build in iOS?

Normally Debug builds have optimisation disabled (-O0) to make debugging easier, whereas Release builds have optimisation enabled (-O3 or -Os), which makes the code run much faster, but also makes debugging harder (but not impossible). You can just go into the build settings in Xcode in the Debug configuration and temporarily turn up the optimisation level - this will keep all the other debug goodies (symbols etc) but hopefully also flush out the Release mode bug. (Don't forget to reset the optimisation level to -O0 in the Debug configuration when you're done!)

How to determine whether code is running in DEBUG / RELEASE build?

Check your project's build settings under 'Apple LLVM - Preprocessing', 'Preprocessor Macros' for debug to ensure that DEBUG is being set - do this by selecting the project and clicking on the build settings tab. Search for DEBUG and look to see if indeed DEBUG is being set.

Pay attention though. You may see DEBUG changed to another variable name such as DEBUG_MODE.

Build Settings tab of my project settings

then conditionally code for DEBUG in your source files

#ifdef DEBUG

// Something to log your sensitive data here

#else

//

#endif

My App doesn't work on the release mode after upgraded to the Xcode 11.4 or later

According to the recommendation of @Paulw, I made a simple app, and I could reproduce the bug.

So I realized the bug has to do everything with the memory issue.

Finally, with this thread, I could solve it.

Why does my app looks different in debug mode and release mode Flutter

That grey error is because you have an error, try looking at your logs.
and also is your app data is from backend? and also yes then please check you have added internet permission in Androidmanifest.xml file

App crashes in Release build but not in debug

There are many reasons that an app might crash in release mode but not in debug mode (e.g. memory allocation differences showing up a bug that actually exists in both builds.) They can take a lot of work to track down, even with a non-beta compiler/language.

You say that the problem goes away if you do as I suggested and build for release with optimisations turned off. Given that the Swift compiler is still in beta and definitely still has the occasional problem—I've seen the compiler simply crash when building optimised builds—this may actually be an optimiser bug.

For now, therefore, I'd defer looking into it. Release without optimisations until we get a full release version of the compiler. Then, turn optimisations back on and see if you still have the problem. If you do, that's the time to start spending your energy trying to figure out if it's a compiler bug or a bug in your own code.



Related Topics



Leave a reply



Submit