Saturday, 22 September 2012

iPhone 3GS ARMv7 issue with XCode 4.5 fixed!

A not-so-happy start
At first I was a bit depressed today, as both my apps failed to compile in Xcode 4.5, plus from yesterday's bad experience - Xcode 4.5 won't generate the ARMv6 code to run on my old 3GS, then found old Xcode 4.3.3 disappeared, only have much older 4.2 left, looks like I might need to keep 2 versions of code !!??

What a mess...

Quickly worked out an action plan - I am going to uninstall Xcode 4.5, install Xcode 4.3 (or 4.4), then install Xcode 4.5 on a different folder - hope that they can co-exist. So that at least I can have the latest 4.3 or 4.4 to test the app on my 3GS, and then test on iOS 6/iPhone 5 (4 inch retina) simulator using Xcode 4.5. That's the best work around I can think of - until I got a replacing device (iPhone 5?) to test with... Hopefully very soon...

New discovery
Then while looking for further details about that ARMv7 error, I saw "PSA: Do not release ARMv7s code until you have tested it" from "Wandering Coder" talking about:

...when ARMv7 was introduced with the iPhone 3GS, ARMv6 kept being the default and there was an added “optimized” setting that built for but ARMv6 and ARMv7 if you wanted it...

Wait, what? ARMv7 was introduced with iPhone 3GS! So it's "iPhone 3G" that doesn't support ARMv7, my iPhone 3GS should be able to run ARMv7 code! But then why did Xcode 4.5 refuse to do it and complaints about ARMv7??

Further investigation...
Have a closer look at the error message again:

ld: file is universal (3 slices) but does not contain a(n) armv7s slice: /Users/qq/Documents/iOS.Dev.Projects/Where is it ?/Buzz.a for architecture armv7s
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Also read that article the second time, slowly. So it's actually complaining about "ARMv7s", not "ARMv7". And looks like "ARMv7" and "ARMv7s" (in the error message) are actually 2 different things!

Problem fixed
Following the article, I checked the "Architectures" values under "Build Settings", and as below, it says "Standard (armv7, armv7s)".

If I double click to modify the value, as shown below, it changed to "$(ARCHS_STANDARD_32_BIT)", no idea what does that mean...

I captured a screen dump as backup, removed the value and added new one "armv7" without the "s", and it works! Xcode 4.5 can now compile my app and install it on my 3GS successfully, yeah!

Huston, we got another problem...
The app starts up on the phone without problem, the splash page loaded, and then it crashed! WTF ##@$$%^&*(!!!...

Error message as below:

2012-09-21 17:32:07.425 Where is it[747:907] *** Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES'
*** First throw call stack:
(0x359c52a3 0x3a3db97f 0x359c51c5 0x343d9897 0x3457e579 0x3445dd45 0x3445cfcf 0x359c89c4 0x3591ffeb 0x3457b733 0x3a7fbd2d 0x316c211f 0x316c14b7 0x316c2dcb 0x35998f3b 0x3590bebd 0x3590bd49 0x358392eb 0x343c5301 0xc0481 0x2d588)
libc++abi.dylib: terminate called throwing an exception 

Spent a lot of time adding different debug/logging but still couldn't workout what's wrong. Then googled the last line "libc++abi.dylib", also couldn't find anything related....

I almost gave up.... Then tried googling the "UIApplicationInvalidInterfaceOrientation" and found a work around!!

Problem #2 also fixed!
I followed the instructions:
1) enable all orientations in project summary
2) as my project uses Cocos2D, and don't have that "application:supportedInterfaceOrientationsForWindow", so nothing to remove
3) Add the extra code below in the RootViewController.m

- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskLandscape;

And it works! Yeah!

I guess I still have to switch back to "ARMv7s" and my old 3GS has to be replaced sooner and later any way, but at least I can hang on to it for a little longer while fixing both my apps for iOS6/iPhone 5!!

And I understand that once I switched to "ARMv7s" all the third party libraries has to be in "ARMv7s" too! Don't want to think about that now, already got lots of things to worry about that....

At least one major issue resolved, what a relieve...

[Update 22/Sep/2012]
You can find some other helpful info in Hacking up an armv7s library by Matt Galloway


  1. Nice.Thanks for the hard work.
    Looks like we have some light at the end of the tunnel (3GS tunnel is still a paying tunnel for me)

  2. Hi,
    Thanks for the comment.
    Unfortunately if you want to go the "Apple" way, most of the things involved are not free....