Base versus Active versus Deployment target - iphone

I know that parts of this question was asked in several variation but I want to make sure I got it right.
Here are my assumptions and understandings which I want to know if they are correct before submitting.
My application assumes features supported by all OS, and so I should:
Set the Active SDK to be the latest (currently SDK 3.0).
Set the Deployment Target to be the lower I want to be supported - iPhone 2.0 and higher?
What exactly is the Base SDK for? should I ignore it if I chose Active SDK to be different and where do I see the Active SDK in the Projects settings?
One final question - is apple allowing to choose iPhone OS 2.0 as the Deployment Target?
Thanks in advance,
BTW - one of my main reason for this question is because when compiling with earlier SDKs apple seems to have a problem releasing the memory for UIImageView animation array when this animation was saved for multiple time usage. This is a known problem that was fixed with SDK 3.0 (by simply setting the UIImageView animation array to nil)

The difference between the Base and Active SDK is that the former is the default SDK set for the project and the latter is the SDK you are currently building against. So it is possible for your Active SDK to be the Base SDK, at which point XCode will use the SDK you specified for the project.
In order to build your app for the widest set of devices possible, you are correct:
Set the Base SDK to the lastest SDK possible (3.0, 3.0.1)
Set the Deployment Target to the earliest SDK possible (2.0)
Apple does allow you to specify iPhone 2.0 as the Deployment Target, but keep in mind any API or framework released after iPhone 2.0 you will not have available to you for use by default. There are techniques to use features from later SDKs, however they are nontrivial.

You should set the Base SDK build setting to the latest SDK that contains all of the features that you intend to use (usually, the latest available SDK), and set the "iPhone Deployment Target" build setting to the earliest version of the OS on which you want to run.
You then need to make sure that you check, at runtime, for any features that may not exist on the earlier OSes.

"Base SDK" is the Maximum SDK you application can support. There's a hard limit here - you can't select a future, unreleased SDK.
"Deployment Target" is the Minimum SDK you are willing to support. It how far back in time you are willing to go.
Xcode appear to create a spurious dependency on "Deployment Target." For example, I can't develop on my iOS 5.1.1 iPod with Xcode 4.5.2 (Xcode 4.5.2 is paired with iOS 6.0), even though the 4.3, 5.0, and 5.1 APIs and Simulators are installed on this installation. I need to use the simulator or jack in my iOS 6.0 iPhone.
The games Apple is playing appears to be causing problems with apps, too. My purchased copy of Elements will not sync via iTunes to the iPod because Elements needs a newer version of iOS to run (it syncs and runs fine on my iOS 6.0 iPhone).
I've got two iPads and one is 4.3. I shudder to think what a mess it will cause.

In general;
Set the BASE SDK to the very latest SDK you are willing to support and test.
Set the Deployment Target to the lowest version of iOS you are willing to support and test.
If you happen to use Base SDK features not available on the deployment target SDK, the app will crash at runtime on older devices, so testing is vital.
An alternative / complementary process would be to use Deploymate http://www.deploymateapp.com/ which does static code analysis to identify problems.
If you are from the android world the analogies are such;
TargetSDK -> Base SDK
MinSDK -> Deployment Target
Lint -> Deploymate

Related

iOS app downgrade compatibility requirements

I was wondering if it's possible to downgrade an app from the app store (ARM binary) to a lower version. For example if the app requires iOS 5.0 or 4.3 or later getting it to run on iOS 4.2 or 4.0.
I understand that the requirements are important as the newer version contains API linked calls only exposed on the newer iOS platform. However, I've many apps that are cabable of running on lower versions are needlessly compiled on newer versions of xcode (just a minor update supports a huge jump on iOS supported version, like iOs 4.0 -> iOs 5.0)
What I would like to do is maybe downgrade an iOS 5.0 app to iOS 4.3 app by verifying that there are no new linked functions apis and thereby adjusting the plist files to the lower vesion? Can otool or class-dump help with this?
Yes, it's possible. Submit a binary with a different "iOS Deployment Target" (in Project > Info and Targets > Deployment Target), even if it is lower than the one you currently have.
You'll need to do extensive testing to make sure your code runs on the various compatible iOS, since a lot has changed with the release of iOS 5 (and subsequently, 6), meaning a lot of functions and methods will not be recognized in those iOS versions.
Regarding finding which API's may not work, here's a small discussion of [Finding unsupported API's with OS version][1]
[1]: finding unsupported apis with os version "Finding unsupported API's with OS version".

What should be minimum deployment target set for iphone application while releasing it to App strore?

Hi I am new to the iPhone App development. Currently I released a small application to App store having deployment version 4.3. But some users are not able to download and install the app due to version compatibility. I searched on internet but I didn't get much solution. Now what version should I set while deployment so that every user can use the application?
You should set your minimum deployment version according to API methods you use in your app, i.e. if you use methods from iOS 5 SDK and don't make your app backwards compatible (with support for older versions of iOS), you should set min deployment version to iOS 5. How would you care about users who don't have newer iOS installed is another question.
Deployment target is the minimum version of iOS that is going to be supported by the application. It means iTunes store will allow the users downloading this application having same or higher iOS version on their devices.
To achieve it developer should take care while using the APIs. The API version should not be higher than deployment target iOS version. If you need to use higher API, you should use
[UIDevice currentDevice].systemVersion to check the target device version.
You should set the Deployment target to that of the lowest OS device upon which you have actually tested that version of your app. Many developers keep or borrow an old non-upgraded iOS device just for that purpose. Otherwise your customers become your alpha testers.
go for 3.0 if your code supports that,
maybe that code changes are needed.

How can I support both iOS 4.X SDK and iOS 5 SDK in my iPhone app?

I am writing an iPhone app in which I want to support the largest user base possible at this point in time (with minimal pain), so I decided that targeting IOS 4.3+ would be a good subset of users for my audience.
I started working in XCode 4.2, but reverted back to XCode 4.1 when I realized that the project templates had changed and everything seemed very intertwined with storyboarding, ARC, etc.
I have built out my application to the point I actually want to test on my device, which has iOS5 installed. When I attempt to use it though, I get this message as soon as I click 'use for development' in Organizer/XCode:
The project's build settings look like this:
My Question Is This: How do I get this application, built in XCode 4.1, to run on both iOS 4.3 and iOS 5 phones?
Are iOS SDKs not backward compatible? I come from Android development in which a less than current SDK will generally work on a newer SDK - is this different in the iOS world? And if so, how is this handled typically?
Any direction on how I should proceed would be greatly appreciated.
You can go ahead and open your app in Xcode 4.2 and it should still work. I've been working on a particular app since Xcode 3.x days and I'm nearly done, chugging along in Xcode 4.2 right now. It shouldn't be a problem. If you want to work with Xcode 4.1 you will be fine, but you won't be ale to use new features introduced in iOS 5.
There are several aspects of "cross-version" development to note.
Testing: You can only test on version of iOS that are included with your SDK, or that are installed on physical devices that you may have. The SDK generally comes only with the latest iOS, sometimes the previous one is included as well, but since Xcode 4 was released, the older SDKs have been progressively deprecated with each release. This is not to say that your app which is linked against the iOS 5 SDK won't run on older versions of iOS. It just depends on how you implement new features.
Features: In order to support older versions of iOS properly, you want to make sure that you don't implement new features without properly checking for the existence of classes, methods, and properties that were introduced in the newer versions of the OS. Unlike Android, you don't have to worry about a million hardware configurations. ;-)
Weak Linking: To support a new feature and still be compatible with older versions of iOS, you need to weak link against frameworks that you are using to implement new features. You can read more about that in the Apple Documentation on Weak Linking.
Deployment Target: The setting that prevents the app from loading on older devices is called the "Deployment Target". If you set this to 3.1.3, then your app will run on iOS 3.1.3 and higher. Remember that if you don't code the the proper version checking, your app may break.
ARC: You can choose to enable or disable Automatic Reference Counting when you create the project. ARC scans your program at compile time only, not at runtime, it doesn't break the app on older versions of the OS.
You need the latest version of XCode and the iOS SDK to install your apps onto your iOS 5.0 phone. That doesn't mean the inverse is true -- you don't need the same version of iOS on your device that you have installed on your computer.
Hope this helps!
You can use the latest SDK and simply set the "IOS Deployment Target" version to 4.3 in the project build settings.
XCode 4.1 doesn't support iOS5 in the sense that Xcode package doesn't contain the iOS5 SDK. So you must return to Xcode 4.2 and target your project for iOS 4.3 (you can also target it for iOS 4.0 with this Xcode version, but you will not be able to simulate it; you can even download older iOS 4.x package versions from the Xcode preferences menu if you really need to simulate them in your device).
You can opt-out of ARC if you want, this choice is given to you when you create the project, so don't worry; but consider that ARC does its magic at compile time only, not at runtime, so your backward compatibility will be kept if you decide to use this technology. Finally if you don't want Storyboard just pick the Empty app template and it will simply put in your project only the basic files. From this template you can create any iOS app, this is the approach I normally follow.

iPhone App Run Different iOS

I am getting a fat binary when I go to upload, and I want to make sure that my application can run across 3.0, well even 2.0. Is there a specific way to make sure that this will show when I go to upload. I am not using any specific iOS 4 features, and I only have iOS 4 in my xCode. How can I test different iOS version?
The only way as I could think of is test your app on real old OS version devices. Since Apple prefers its users to upgrade to new OS version as soon as possible, they don't actually provide an official way for developers to test such backward compatibility.
Another relevant questions would be, "can I downgrade my device OS version to an old one, so that I can test my app on them?" I once did a research on SO and other Apple forums, and the result I got was NO, we developers don't have a way to "officially" downgrade our device OS version. Yes there are exceptions, you can try jail-breaking and then downgrading.
For jail-breaking / downgrading your OS version, check this post, A TimeMachine taking my iDevice back to 3.1.2? .
Edited: It's actually pretty easy to make sure that users with old OS versions can downloaded and install your app. All you need to do is set the Deployment Target in Xcode to the lowest OS version you want (iOS 3.0 would be the lowest in Xcode 3.2.5).
However, you need to bear in mind that such Deployment Target only ensures that your app can be downloaded and installed on such old version OS devices. They don't ensure compatibility during runtime. You still need to test your app on real old OS devices to ensure compatibility.
I dont think u need to worry about app version 3.0 below because it is not supported anymore. but how to test on different version, make sure change the iOS deployment target as Thomas refered.
There is no currently supported way to do this.
No current Simulator or Xcode tool will ensure that an app is completely compatible with an OS version older than the SDK used. The 2.0 SDK is not compatible with the current development tools. There is no officially supported way to downgrade a device.
Furthermore, Apple no longer even accepts app submissions that have a deployment target lower than 3.0.
Even most old 1st gen devices, if you can find one on eBay, have been upgraded to iOS 3.1.3. But if you have access to an old device running iOS 3.1.3, you can use that for testing. Many developers keep an old used iPod Touch around for just his purpose.
People with devices running something older than 3.1.3 are not only a really tiny percentage of the installed base, but are very unlikely to be still buying apps for that device. Even large developers with staff and legacy hardware available for this testing rarely waste the time on this market.
Look into Project -> Edit Project Settings -> iOS Deployment Target: 3.13. And then build?
Edit according to comment: You still need to ENSURE your code is within the runtime scope, i.e. do checks like 'respondstoselector' before calling methods in question.

Building for lower version number for iPhone distribution

If I have built an app for 3.1.3 (using for instance the frameworks within the 3.1.3 folders) how do i then target a version below that (3.1.2) for the ad hoc and distribution builds?
Do change the Base SDK in the Project Info (Distribution) settings or the Target Info (Distribution) settings? (I've always been unclear on the diff between these two windows)
Base SDK must be 4.0 (or 3.2 for iPad). You don't get any other choice with the new SDK.
Therefore it is the "iPhone OS target" value you must change, found within the project settings. Here you can wind right back to OS2.0 if you wanted!
When you do this and set any earlier version than 4.0/3.2, any new calls for the later versions will be loosely bound; in other words, it will run on the old OS but will crash if any new calls are executed. Therefore you need to check if newer calls are supported. Use the -respondsToSelector method, or alternatively check UIDevice to see what OS version is currently running.
Edit: if you're using Xcode 3.2.2 or earlier then you get a wider choice of Base SDK. If you set a lower base SDK then any new commands won't be available/won't compile. This can be useful for example if you want to guarantee an app running in iPhone OS3.0. However this option disappears for historic OS numbers in Xcode 3.2.3 as mentioned above.