9

So i've run into quite a problem. It seems that ASIHTTPRequest just does not want to work in a production build.
Everything works great in debug. However, once I build for production the following code just doesn't want to run. It doesn't hit either block complete nor failed. I have also tried using selectors, with a delegate but those do not get called either.

__block __weak ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:URL];
[self performSelectorOnMainThread:@selector(startSpinner) withObject:nil waitUntilDone:NO];

[request setCompletionBlock:^{
    [self performSelectorOnMainThread:@selector(stopSpinner) withObject:nil waitUntilDone:NO];
}];

[request setFailedBlock:^{
    [self performSelectorOnMainThread:@selector(stopSpinner) withObject:nil waitUntilDone:NO];
}];

[request startAsynchronous];

I know it's kind of a bad description of my problem but does anyone have the slightest clue as to what could possibly cause this problem?

endy
  • 3,872
  • 5
  • 29
  • 43

1 Answers1

22

It looks like there's a bug in ASIHttpRequest, causing this crash when running with Release mode optimizations.

What worked for me is turning off optimization for the following 2 files: ASIFormDataRequest.m ASIHTTPRequest.m

Do this by selecting the target project, select the file in "Compile sources" section of the "Build Phases" tab; and add -O0 (capitol O zero).

You can read more about it here

adamsiton
  • 3,642
  • 32
  • 34
  • 1
    How to add multiple flag ? I need to add this flag -fno-objc-arc to enable working in ARC also you said I've to add this flag -O0 to enable working in release mode, how can I add 2 flags ? – Atef Jan 27 '14 at 00:49