Search code examples
iosobjective-cdebuggingreleasetestflight

Difference between debug and release


I have an app that runs a synchronization algorithm.

When I build and run it in debug mode (onto my iPhone 5) it all works fine.

However, when I archive it and upload it to TestFlight and then download and install to the same iPhone 5 then part of the sync doesn't work.

It doesn't crash or anything, it just doesn't run that part of the sync.

The stupid thing is that it is a line of code inside a single function that isn't running. Everything else in that function does run.

I have no idea where to start looking for this.

EDIT

With help from Mindaugas I've found exactly why and which bit of code is not being run.

The function is...

- (void)uploadData
{
    NSLog(@"pushing photos");
    for (StoredImage *storedImage in self.recordArray) {
        NSURL *url = [self urlForImageUpload:storedImage];

        if (url == nil) {
            continue;
        }

        ImageUploadOperation *uploader = [[OJFImageUploadOperation alloc] init];
        uploader.image = storedImage.image;
        uploader.url = url;
        [self.recordQueue addOperation:uploader];
    }
}

When I set the optimisation level to "Fastest, Smallest" it seems to mess the order of this function up.

When it enters I can see that there is a single object in the array and it enters into the loop. But then it completely skips past the first line NSURL *url = [self urlForImageUpload:storedImage]; and goes to the end. So the upload never actually starts and it moves onto the next item.


Solution

  • Release configuration by default uses different code optimization than Debug configuration, so some code lines can be optimized and skipped

    You can check/change configurations at Target -> Build Settings -> search for Optimization Level