XCode iPhone OS Deployment Target Tool - iphone

Problem
I'm currently stuck trying to figure out what "iPhone OS Deployment Target" setting to use. I do not want to write conditional code right now, so I'd like the lowest version that runs my application fine.
At first I thought it would be 2.0 as I wasn't using any 3.0 features, but then i realized that AVAudioRecorder is a 3.0 API. I don't want to be manually checking EVERY function I use in the documentation.
Question
Is there a tool that will check the OS availability of each functions you call in your code to figure out what the Deployment Target should be? That tool could be a good old compiler, but the latest version of the iPhone SDK does not come with the PRE-3.0 SDKs.

There is a way for checking desired older iOS. For example: I have installed the sdk 4.1 and tested the compiling for the 3.1 target.
http://0xced.blogspot.com/2010/07/using-sdk-313-with-iphone-sdk-4.html

There is no tool to do that, testing on dedicated devices is the way forward.
Depending on what you want to do, conditional code based on the SDK version is probably a common task on iOS development. Not only because new APIs come along, but because Apple does change the behaviour of given APIs on new iterations of the SDK unfortunately. So I wouldn't be scare of branching the code when needed.

There isn't such a tool. Your best bet is to check the docs, and test on devices with different versions of the OS installed.

Related

I am using Xcode 3.2.5. I have iAds running. Confused about about targest, iOs versions

Trying to keep up with the curve. I'm reading almost too much and is sending me in a tail spin. Is there a one stop link which will tell me what my target should be to run my app on all platforms based on what frameworks I have included? I make heavy use of Mapkit, and want to include iAds. My current apps seem dead on 3G.
Does Apple force you to support only the latest iOS? I have no problem with that, but not sure if someone who has and ancient 3G, how do I tell them, NO I don't support your phone, please upgrade?
Set your project's base SDK to the latest version of the SDK. Set the deployment target to the oldest version of the OS that you plan to support. You can use features introduced in versions later than your deployment target, but you'll need to check for them before you use them, else your app will crash.
Read the release notes for each version of the OS to get a good idea of what features were introduced when. In fact, make it a habit to read the release notes thoroughly each time a new version comes out.
iOS 4.2 runs pretty well on an iPhone 3G, so there's no need to drop support for the 3G anytime soon. If your apps currently don't work on the 3G, fire up your debugger and figure out why. What version of iOS are you running on that device? Where does it crash? This is typical debugging stuff.

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.

Which version of the iPhone SDK should I use for an OS4 app?

I'm wondering if I will have compatibility issues with OS4.0 if my app is built with the 4.1 SDK, or is this a non-issue?
The short answer to your question is: Use a Base SDK Version of at least 4.0 for your application and a Deployment Target Version of exactly 4.0.
I've downvoted both answers because they are wrong or at least incomplete.
When building applications there are two settings that you should be aware of:
There is the Base SDK Version which defines against which version of the SDK your application will be compiled.
There is also the Deployment Target Version which defines the lowest version of the iOS that your application requires. You can set this to as low as 2.2.1 in Xcode but the App Store will not accept versions lower then 3.1.3 at the moment.
The Base SDK Version can be higher then the Deployment Target Version. This simply means that your application is backward compatible with older version of the iOS. This also means that your app needs to make decisions at runtime to be sure not to use newer functionality when running on an older version.
For example, the MFMessageComposeViewController was introduced in 4.0 so if your app has been configured to also run on 3.1.3 then you should use NSClassFromString() to find if that specific class is actually available before you use it.
There are many questions here on Stack Overflow on how to discover available functionality so I will not repeat those techniques here.
And a somewhat important note:
Behaviour does change across OS releases. There were a pile of changes in 3.0 (we had issues with UITableView/UITableViewCell):
Some changes happened on old apps (e.g. compiled for 2.2.1). I forget what these were.
Some of them were in the toolchain (I think they changed how nibs were compiled with ibtool; it was something like setting both an image and a custom view for a UITableViewCell). This happened when we upgraded the SDK on the build server, even if we didn't touch "Base SDK"
Some of them happen only when you compiled with a Base SDK of 3.0 (UIKit automagically detects which version you've linked against and has backwards-compatability modes for some things)
Additionally, there were some runtime/C++ changes in GCC 4.2, which meant a GCC 4.2 app running on OS 2.2.1 crashed when casting unsigned int/long to float/double or using std::ostringstream. I've since added a check for GCC version.
So no, compiling with a newer SDK can result in issues — you might not want to risk it if there are time constraints (you don't have time to implement multitasking support, or you don't have time to do a complete re-test and fix all the bugs, or so). Or maybe you still want to support 2.2.1 for some strange reason (4.0 dropped 2.x "device support", which effectively made it impossible to debug apps on 2.x devices).
Usually nothing breaks across minor OS releases (discounting 3.1/3.2). I'd recommend upgrading SDKs as soon as you have the time; don't shy away from new features just because old OSes don't have them.
Depending on the APIs you will be using. Let's say you want to implemented in-app texting (MFMessageComposeViewController) and want ALL of your end-users (will be defined as EUs) to access that feature then you'll have to compile against iOS 4.0. But let's say you want the in-app texting to be optional and a "plus" for your EUs, you'll just compile your app against iOS 3.0 (let's say).
Hope I answered your question :-)

iPhone - validating code for a specific SDK version

Suppose I have my project using Base SDK = 4 but set the Target OS to 3.
Now suppose that I may have used some functionality that belongs to 4, on a framework that already exists on 3.0. So, it is not a matter of using a framework that doesn't exist on 3, it is a matter of using a method that exists on 4 but not on the same framework on 3.
Is there a way to check which lines of my code are illegal on the target OS?
I ask this because when I set Base SDK to 4, Xcode will allow me to use instructions that belong to 4.0, even if the target OS is 3. This will simply make iPhone 3GS crash and will not be detected during compilation.
thanks
As far as I know there's no way of doing this from the newest Xcode.
You can install a previous version with the iPhone 3.0 SDK, build the project and check the compiler warnings. This method is not foolproof as it doesn't cover all possible cases.
And I highly recommend that you test your app in a iPhone 3.X device anyway. Some APIs behave differently, even if their signature hasn't changed.
Cocoa with Love has a good roundup of working with older OSes. I think this might answer your question:
http://cocoawithlove.com/2010/07/tips-tricks-for-conditional-ios3-ios32.html

Run application on the older iphone os

my new app update runs only on 3.1.3 OS and some people who have older os [3.1.2] can't run the application on the iphone .. does it way to solve this ? and my app runs on 3.1.2 iphone os?
You need to rebuild your app update targeting the 3.1.2 OS and resubmit to the AppStore. You also need to isolate any 3.1.3-specific features you are using.
To be more specific on Franci's answer:
You need to set the Deployment Target build setting in your target's settings. Set it to the lowest version of iPhone OS you wish to support.
After doing this, you should always compile your app against the latest SDK, to benefit from bug fixes and performance improvments.
If you use any features from the latest SDK that aren't available on prior OS versions, you should weakly link to the framework in which that feature is defined, and use conditional checks to see if the API exists before using it. If the API doesn't exist at runtime, your app should gracefully fall back onto a default behaviour.
If your app doesn't use any APIs which are not in prior OS versions then you don't need to worry about that.