Xcode 4.5 and iOS 4.2.1 incompatibility
Asked Answered
S

6

36

The latest release notes indicates 4.2.1 and lower will not be supported, we now have to use 2 version of Xcode to develop when supporting older devices?? This is going to be difficult to support older devices if we want to develop iOS6 AND support 4.2 and lower.

I don't think Xcode 4.4 will support iOS6. So this is the issue. How would developers easily support these platform without so much hassle?

Styracaceous answered 17/9, 2012 at 16:11 Comment(0)
A
29

You can do this, but it requires some minor Xcode hacking, and some sacrifices. Depending on what you mean by "support iOS 6", this may or may not be sufficient for you. If you just want your app to run on iOS 6, then this should work. If you also need your app to incorporate new iOS 6 features, then it won't.

    (Note for others who don't have a problem using multiple versions of Xcode: this similar question has answers that do allow you to also use new iOS 6 APIs and directly target armv7s)

See basic instructions on chpwn's blog here (but read the rest of this below, too!)

Basically, you can use Xcode 4.5 to build for iOS 4 and above, but then you can't take advantage of the new iOS 6 only features. So, you're really building for iOS 4 and 5, and assuming that the app will run fine on iOS 6 (which should be true, but you'll need to test this yourself).

You'll need to copy the iOS 5 SDK folder

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.*.sdk

from an old Xcode installation (which you'll need to keep around briefly, or reinstall to a non-standard location). You'll then set the Deploy Target in your Build Settings to iOS 4.0 (or whatever minimum OS you want). You may need to open the project.pbxproj file in a text editor to set this manually:

IPHONEOS_DEPLOYMENT_TARGET = 4.0;

You'll also need to set the Architectures to armv6 and armv7. You cannot directly also target armv7s. But, that doesn't mean your app won't run on iPhone 5. armv7 executables should run on iPhone 5, simply without any optimizations added in armv7s. It's just that compatibility doesn't work in the other direction (e.g. armv7 executables don't run on an armv6 iPhone 3G).

enter image description here

There's also a step that might be necessary, that's not mentioned in chpwn's blog. You may get these warnings (which really are errors, because Xcode won't generate your executable properly):

warning: no rule to process file '$(PROJECT_DIR)/main.m' of type sourcecode.c.objc for architecture armv6

In order to fix this, you'll need to setup a custom Build Rule for your target that tells Xcode to use LLVM GCC 4.2 to generate armv6 code. Define the rule for files matching the pattern *.[mc]:

enter image description here

This will be a different compiler than the Xcode default, and you may need to adjust some of the syntax in your Objective-C code. Even though many people wanting to do this probably wrote their apps before ARC, it is important to note that LLVM gcc 4.2 does not support ARC.

Finally, you probably will still see warnings from Xcode about iOS deploy targets less than 4.3, and armv6 not being supported. Those, I found, were not problems, and could be ignored:

enter image description here

Running lipo -info on my app executable after this shows the desired result:

lipo -info MyAppName
Architectures in the fat file: MyAppName are: armv6 armv7 
Acrobatic answered 25/10, 2012 at 4:29 Comment(5)
huge thanks, you made my evening! I was struggling with XCode using article by chpwn, but without any luckMicroscopium
what if I have files that are *.mm how do I include those in the *.[cm] syntax? thanksMurphy
@indiekiduk, I don't really use C++ in my iOS projects, but I would guess that you could just do Add Build Rule a second time, and this time, define the build rule for *.mm, also pointing to the LLVM GCC 4.2 compiler.Acrobatic
Note that you can also add armv7s to supported archs : https://mcmap.net/q/337362/-how-to-support-both-armv6-and-armv7s-for-release-build-in-xcode-4-5Bridesmaid
I 'd like t highlight that the important point is to use LLVM GCC 4.2 (instead of Apple LLVM GCC 4.2)Kunstlied
L
22

Xcode 4.5 makes iOS 4.3 the earliest supported operating system, which effectively orphans the original iPhone and the 3G.

If you want to support iOS versions earlier than 4.3, you will need to keep around a 4.4 version of Xcode.

To be a bit clearer : you cannot easily (meaning Xcode does not out-of-the-box) support pre-4.3 devices and use iOS 6 features in the same app. That's because iOS 6 features require XCode 4.5 which also sets iOS 4.3 as the minimum supported OS.

So, you have 3 choices :

  1. Continue using XCode 4.4. You'll be able to target pre-4.3 iOS. You won't be able to take advantage of iOS 6 features, but your app should run fine on it assuming you perform adequate testing on actual iOS 6 devices.
  2. Migrate to XCode 4.5. You won't be able to target pre-4.3 iOS, but you'll be able to take advantage of iOS 6 features.
  3. Make two versions your app. Build one version with XCode 4.4 (as in option 1), and the other with 4.5 (as in option 2). From the point of view of distribution, these will be 2 separate apps, they'll each have their own bundle ID, etc. You will have two entries in the app store.

If you are comfortable going beyond what is supported directly by Xcode, see Nate's answer.

Lusatian answered 17/9, 2012 at 16:34 Comment(7)
+1 for answering rather than speculating on his business requirements.Schiedam
How would one develop in 2 versions of Xcode? I see how you could create 2 different binaries, but then how would those two binaries be managed in the App Store? Here is a discussion on this topic: #12575351Superimposed
You can't both support pre-4.3 devices and use iOS 6 features in the same app.Lusatian
Same with ios 5, but xcode supporded 4.2.1. I don't think you know what you are talking about, or what we're talking about.Styracaceous
+1 for the answer, Paul, but your previous comment ("you can't both support pre-4.3 devices and use iOS 6 features in the same app") isn't actually true. See the solutions to this answer. I know this is true by default with Xcode, but there are ways to get around the default limitations. Basically, you do what you suggest in (3), but then use lipo to merge the executables for armv6, armv7, and armv7s together into one bundle that gets submitted to Apple.Acrobatic
@Nate, I stand corrected. I should have said "You can't easily support ...".Lusatian
That would be a great way to put it :)Acrobatic
A
2

The original iPhone and iPhone 3G are the only devices that don't support iOS 5. The iPhone 3G is now 4 years old. You may want to consider dropping support for iOS 4. If you don't want to do that, I think you'll have to develop in two different versions of Xcode.

Altonaltona answered 17/9, 2012 at 16:20 Comment(4)
iOS 4 devices still have a significant market share. This is especially for business apps, those device still have plenty of power to run them. I'd imagine most apps would still want to support them, at least for another year till it really does fade out.Styracaceous
most of remaining iOS 4.X users will upgrade to an iPhone 5. With iOS 6 out there is no point in wasting effort on 4. With our next version we are officially giving up on 4.X.Necking
Is funny why no-one is answering my question, after all the trying/convincing of the people for me to not support 4.2.1, I still need to for business reasons. So, again, is anyone out there that needs to support 4.2.1 AND 4.3 and above, if so, how are they coping?Styracaceous
@Scott The first and second generation of iPod touch also do not support iOS 5. en.wikipedia.org/wiki/…Ague
S
2

I assume that the dropped support for iOS 4.2.1 is not the core problem. In fact, I tried to work around this and do the following:

  • Build the app with iOS 6 SDK, setting deployment target to iOS 4.2.1 (which works).
  • Pack the app for ad hoc installation and install the app on an iOS 4.2.1 device (iPod touch 2G).
  • Test the app.

However, installation fails. The reason here is - afaik - not the iOS version. The reason is the architecture. XCode 4.5 no longer allows you to build for armv6. It only builds for armv7. On the other hand: all device which have armv7 or better can run iOS 5. The only devices which do not support armv7 are iPhone, iPhone 3G, iPod touch 1G and iPod touch 2G.

So for me the question is: can you build for armv6 with XCode 4.5 and iOS 6 as base SDK?

Edit: Which you cannot do, because the iOS 6 base SDK is not available for armv6. Right?

Sundog answered 13/10, 2012 at 13:23 Comment(0)
D
0

I think that targeting to 4.3 is the best choice, according to ios version statistics

Dactylology answered 28/9, 2012 at 7:7 Comment(1)
On the contrary, every iOS 4.3 device ever made can be upgraded to iOS 5 and/or 6. Going to the trouble of supporting iOS 4.3 is a waste of time. Targeting iOS 4.2.1 is what gains you millions of devices that you would otherwise be abandoning. See my comment on answer above.Ague
S
0

Try to set the project settings manually using IPHONEOS_DEPLOYMENT_TARGET=4.0. However, I don't know if there is any side effect.

Sundstrom answered 8/10, 2012 at 10:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.