Why is Xcode archive different from Xcode for build / run on iPhone

I have an iPhone app developed on Xcode 4. It works correctly in the following environments:

  • iPhone Simulator (iOS 5 version)
  • IOS 5 device (running from archive)
  • IOS 5 device (running from an Xcode build)
  • IOS 4 device (running from an Xcode build)
  • IOS 3 device (made from the Xcode assembly)

However, when I put an archive that works in iOS 5 on an iOS 3 or 4 device, it acts funny. The exact same code works fine when launched from Xcode on the same device.

When I say that it acts funny, it animates the sliding UIView on the wrong axis. I am actually doing a rotation conversion on a UIView before I animate it. But then again, it works great when launched directly from Xcode, even on iOS 3 and 4. It only works in the archive and only for iOS 3 and 4. The archive works fine in iOS 5.

The rotation is performed by a static call in the helper class:

+ (UIImage*)rotateImage:(UIImage *)image { CGRect bnds = CGRectZero; UIImage* copy = nil; CGContextRef ctxt = nil; CGImageRef imag = image.CGImage; CGRect rect = CGRectZero; CGAffineTransform tran = CGAffineTransformIdentity; rect.size.width = CGImageGetWidth(imag); rect.size.height = CGImageGetHeight(imag); bnds = rect; bnds = swapWidthAndHeight(bnds); tran = CGAffineTransformMakeTranslation(rect.size.height, 0.0); tran = CGAffineTransformRotate(tran, M_PI / 2.0); UIGraphicsBeginImageContext(bnds.size); ctxt = UIGraphicsGetCurrentContext(); CGContextScaleCTM(ctxt, -1.0, 1.0); CGContextTranslateCTM(ctxt, -rect.size.height, 0.0); CGContextConcatCTM(ctxt, tran); CGContextDrawImage(UIGraphicsGetCurrentContext(), rect, imag); copy = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return copy; } 

Animation is performed using:

 // The first image should fall from top. CGRect rect = boardView.frame; rect.origin = CGPointMake(VIEW_IMAGE_X_POS, 0); boardView.frame = rect; [myView addSubview:boardView]; // The starting image comes down. Then passes control to the next animation routine for the clones. [UIView beginAnimations:@"addStartingImage" context:boardView]; [UIView setAnimationDuration:1.2]; [UIView setAnimationDelegate:self]; [UIView setAnimationDidStopSelector:@selector(startingImageDidStop:finished:context:)]; // Add the new image rect = boardView.frame; rect.origin = CGPointMake(VIEW_IMAGE_X_POS, myView.contentSize.height - 108); boardView.frame = rect; // End the animation [UIView commitAnimations]; 

Everything else is working fine. Any thoughts?

+4
source share
2 answers

Try disabling compiler optimization.

Something is wrong with the UI on older iOS 3.x and 4.x ARMv6 devices when compiling the release build. I have no idea why, but disabling compiler optimization will help.

Disabling Thumb can also help you solve this problem, you can go to the build settings and hover over the option โ€œOther C flagsโ€. Click the Small Plus button that appears to the right of this option and add a condition for the ARMv6 architecture. Do it again to create it for the ARMv7 architecture. In the ARMv6 architecture, add the optional compiler flag -mno-thumb .

Thumb turned off for ARMv6

+3
source

The code looks fine. The only problem I see here is: rect.origin = CGPointMake (VIEW_IMAGE_X_POS, myView.contentSize.height - 108);

Try hard-coded the value of myView.contentSize.height . It is possible that view / window may not return contentSize in accordance with the updated current orientation of the device.

0
source

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


All Articles