The application works fine with the debug build, but the build fails to release, what could be the possible reasons?

I have Xcode 4.3.1, iOS 5.1 and ARC enabled to build my application.

Now the application works fine in the debug assembly, but it fails to release the assembly. What could be the reason for the difference? I just rely on ARC for resource management. I looked at the crash log, this indicates that a memory link has already been issued. What will be the common mistakes that can cause a problem when creating a retail network when using ARC ?

The following is what I got from the crash log

 Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Codes: KERN_INVALID_ADDRESS at 0x6f636552 Crashed Thread: 0 

EDIT

The purpose of the application deployment is iOS 5.0. I use Internet connections, the current crash occurs during the "rendering" of the data returned from the web service to show on the UITableViewController . The entire application uses ARC , with the exception of a few source files from a third party, for which I have disabled ARC .

+6
source share
3 answers

Whenever this happens to me, it seems because release builds are more aggressive in removing weak links. If you mistakenly assigned something to a weak property (for example, if you add subviews in which you will also keep weak links) before you have any strong link to it, this may work on debugging and release crashes. For example (pseudo code)

 @property (weak) UILabel * label; ... self.label = [[UILabel alloc] init]; [self.view addSubview:self.label]; ... self.label.text = @"hello"; 

I saw that this leads to a failure to work with errors during release failures and imperceptibly debugs during debugging.

+4
source

I may not have an answer, but I'm going to list a few attempts:

  • Make sure that you do not pass objects to methods without a “handle” on it by your side. And the example will pass an instance of the handler class to the method that expects the delegate. The method does not save this instance, and therefore it is freed before it even calls the method.
  • Check your macros before the compiler to make them safe for DEBUG and RELEASE assemblies. A good example is the if on a macro that is removed in release builds, and the if does not cover its curly braces.
  • If you are dependent on compiler definitions to enable / disable certain parts of your code (using the #if conditions), make sure that the necessary settings are specified in the assembly configuration.

If I can come up with more, I will try to add them.

0
source

Do you have another goal for release and debugging? Check if the files are listed correctly for the purpose of the release.

In our case, the category on UIButton was not detected by the release target. The ad-hoc build went fine until someone called the method implemented by this category. Since we did not store the archive from the Ad-Hoc assembly, there was no way to debug the failure. (lessons learned)

Not sure if it is listed as EXC_BAD_ACCESS in the crash log, but may help someone identify their crash on release.

0
source

Source: https://habr.com/ru/post/912161/


All Articles