How to build for armv6 and armv7 architectures with iOS 5
Asked Answered
T

6

96

In iOS5 Apple drops the armv6 architecture from the ARCHS_STANDARD_32_BIT.

In order to keep the support for iPhone3G I still want to compile in armv6 even in iOS5.

Did anyone find a solution for this?

Tramp answered 20/9, 2011 at 16:40 Comment(0)
E
96

I just built something today specifying a deployment target of iOS 4.0. With only armv7 specified in Architectures, Xcode warned me that to support anything below iOS4.2 I had to include armv6 in Architectures. Just edit that field, click the "+" button when the dialog pops up and enter the literal "armv6".

In my case, we want our app to work under iOS4 and iOS5. We had to make some modifications so it would work correctly under iOS5, but all those changes were done with iOS4-friendly code changes.

We also added some iOS5-specific capabilities in a manner that allows the app to run without crashing under iOS4. Specifically, we tested for iOS5 capabilities before trying to use them, and linked iOS5-only libraries as Optional.

So, supporting iPhone3G in an iOS5 world could just as easily mean "we want our app to run on iOS4 and above (regardless of any iOS5 feature use)" rather than "we want to make sure our app runs on an older device running iOS5". There's a difference here; think about it. :-)

Anyway, adding armv6 support back in is very easy. And I guess the point is this: At some point, when there are no more armv6 devices out there to worry about (for whatever reason) you won't have to build for it. Apple's view is everyone should upgrade to the latest hardware as soon as possible. So in that world, there is no need for the tools to default to anything but the latest and greatest too. :-) Fortunately (or not), we developers live in the real world and recognize that you have to support older stuff for a while. And I guess the Xcode dev team knows this too, which is why you can add armv6 support back in quite simply.

Expulsive answered 20/9, 2011 at 18:46 Comment(6)
Thank you for your precise answer :-) Indeed I want to be able to run my app on an iPhone 3G with iOS 4.2.1 or lower (limiting to 4.0) and have some iOS 5 specific features for current devices. I did not try with simply adding "armv6" in architectures, I was looking for a environment variable like ARCHS_STANDARD_32_BIT and I've just found ARCHS_UNIVERSAL_IPHONE_OS but it didn't seems to work.Tramp
Wanted to add that a lot of solutions out there suggest that it should say "armv6 armv7" -- this did not work for me. Currently only "armv6 $(ARCHS_STANDARD_32_BIT)" works for me, meaning don't get rid of what's there, just add "armv6" to the Architectures settingAten
I did all of this and my build was still failing - reason was I had an (unused) Release build set to a Deployment Target of iOS 5.0 while the Debug and Distribution were set to 3.0 and this seems to stop xcode building for armv6. Setting the Deployment target to 3.0 for all builds fixed the issue.Chrismatory
Thank you so much! I just upgraded to Xcode 4.3 and my app would no longer deploy to the iPod Touch I'm using for development (iOS 4.2.1). I added armv6 to the Architectures setting, and boom, it worked! :)Olive
It didn't work for me (even after adding 'armv6'). The app didn't even appear on my iPod touch. But then I discovered that 'Required Device Capabilities' (under the info tab) had armv7 in it. I just deleted it and it started running perfectlyContinuous
I generally use $(VALID_ARCHS), which works for me. I've just found that new projects also add a capability requirement 'arm7'. I just deleted that and all works fine.Holy
K
51

The simple answer is that you have to change the current settings from "Standard (armv7) - $(ARCHS_STANDARD_32_BIT)" to just be "armv6" and "armv7". See the image below. You have to delete the line with the previous settings for it to work.

Correct settings for armv6 and armv7

Kra answered 16/10, 2011 at 16:49 Comment(1)
Thanks for explaining this with an image - it really made it clear.Wafture
E
11

also make sure you set this in Project AND Targets ... cost me an hour to figure that out. had set it for one but not the other. hope this helps. GLTA

Electrostatic answered 16/10, 2011 at 20:28 Comment(1)
Also, if you have any libraries, you have to set it in project and targets there.Bonnet
E
9

I think there's a reason why Apple dropped armv6 from the standard setting.

I have compiled armv7/armv6 with iOS5 SDK, however, the armv6 compiler produced wrong code in release mode. After hours of finding a workaround (trying llvm or gcc with different optimization levels) I give up.

So, I am going back to iOS SDK 4.x as long as I support older armv6 devices.

Example of code:

// myView center=(160, 100)
CGPoint p=myView.center;  
// now p=(100,100) (what the heck?)
p.x=myView.center.x;
p.y=myView.center.y;
// now p=(160,100) 
p.y+=100;
// now p =(200,200) (what the heck?)

Maybe I'm have some memory corruption, however, on the armv7 compiler and on iOSSDK < 5.0 it behaves as expected.

Best regards

Etiquette answered 11/10, 2011 at 9:20 Comment(3)
I'm also seeing strange bugs in armv6 builds on older devices. Did you figure this out, or really go back to an earlier XCode? Also I note that they don't let you download the older SDKs any more!Proficient
This is a known issue with the LLVM Compiler 3.0 in Xcode 4.2 and CGPoint / CGSize structs: devforums.apple.com/thread/122059?tstart=15 . Disabling building for Thumb on armv6 prevents these kinds of errors.Hoard
Wow! I'm so glad for your answer, this is happening to me too.Burch
G
7

Not sure if this is actually a solution yet, but I have discovered that replacing the defined string in "architectures", which was $(ARCHS_STANDARD_32_BIT), with "armv6 armv7" allowed me to compile with iOS5 as a base and iOS4 as a deployment target, and pass validation .

I am not using any IOS5-exclusive libraries or calls, but intend to in my next release.

Grettagreuze answered 6/10, 2011 at 15:26 Comment(0)
G
1

I did not need to replace $(ARCHS_STANDARD_32_BIT) with just armv7 for the app to compile and be uploaded to the App Store.

As suggested by MarkGranoff, I simply added armv6 as plain text, by hitting plus and just typing it in on line two.

Galatia answered 2/3, 2012 at 12:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.