I have an app that works fine in the debug mode on the device. I sent the app to the App Store and it works fine, except for iPhone 3G.
My test(debug) device is an iPhone 3G and it works just fine in debug, but when I downloaded the app and installed it via the App Store, it didn’t work on my iPhone as well.
I had some NSLogs in the code and thought that that might be the problem, but even after the removal of NSLog, the same thing happens on iPhone 3G.
The problem is that I’m using the following code:
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
mouseSwiped = YES;
UITouch *touch = [touches anyObject];
CGPoint currentPoint = [touch locationInView:self.view];
currentPoint.y -= 20;
UIGraphicsBeginImageContext(self.view.frame.size);
[drawImage.image drawInRect:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 5.0);
CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 1.0, 0.0, 0.0, 1.0);
CGContextBeginPath(UIGraphicsGetCurrentContext());
CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentPoint.x, currentPoint.y);
CGContextStrokePath(UIGraphicsGetCurrentContext());
drawImage.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
lastPoint = currentPoint;
}
and on an iPhone 3G this does not draw right. It just makes horizontal lines. This works fine on other devices.
What could be going wrong here?
There is a known bug with the LLVM compiler in Xcode 4.2 that leads to incorrect results when using CGPoints, etc. on the ARMv6 architecture. This is detailed in this thread on the Apple Developer Forums. ARMv6 is what is used for pre-iPhone 3G S devices (such as your iPhone 3G), so that’s why you’d see it there.
The bug is related to incorrect Thumb code generation for the ARMv6 builds of your application. I describe how to selectively disable Thumb for just that older architecture (while preserving performance on the unaffected ARMv7 build) in my answer here.
Some people have said that Xcode 4.2.1 has a fixed version of LLVM which addresses this, but I can’t confirm that.Read gparker’s comment near the end of this Apple Developer Forum thread to see where this has been fixed.