regarding check for base sdk in application code - iphone

I want to check if a particular device is having base sdk 5.0 or 4.3 or 4.2 or any other iOS sdk version. To put it more clearly, I want a particular code to run only and only if the iOS sdk version is 5.0 (using the APIs only supported in iOS 5) and if it is less than 5.0, then I want a different code to run. Does anyone has any idea about this???

Use the - (BOOL)respondsToSelector:(SEL)aSelector to check if the object has iOS version specified selector.

I would try setting application properties in Xcode. Start reading here.

Related

Create project for iOS5 on XCode 4.6

Tell me please, how can I create project for iOS5 + in my XCode 4.6, where all builds for iOS6 +
I change Deployment Target
And how change base SDK? Or maybe I cann't change it?
And what I must do, that my XCode show me warnings if I will try use methods, that can be used only in iOS 6+?
First you should understand a few things. Deployment target is the minimum OS version that your app supports. If you set into iOS 5.0 you can assure that it's support iOS 5.0 and above. Base SDK is the SDK which is used to compile your application. Always use latest SDK available.
If you want to create app that support iOS5.0 and above set deployment target as 5.0. Then use latest SDK available. The reason is that if you change base SDK to some lower version, your app may not support ios6 since some of the methods are deprecated in iOS6. If you compile it with latest SDK it shows warning. You can test your app by installing different simulators to check wether it is working properly. Mainly you need to handle orientation issues since it is different in both.
You can use conditional compilation. Remember not use autoLayout and attributed strings. Which wont support in ios5
For your first question as far as I know ios 5 api will also be supported in later versions. You should set your target to ios 5.0 (via your project target settings) for making sure that none of the ios6 methods are used (or else a compilation error will prevent you from building it).
In order to support new features and check if ios6 is available on the device you have two ways :
During compilation (so you can still build your app with lower targets and newer together) use the following macro
#if __IPHONE_OS_VERSION_MIN_REQUIRED > __IPHONE_6_0
// Your ios6 code goes here
#endif
2: During runtime : [[[UIDevice currentDevice] systemVersion] floatValue] > 6.0

Run iOS 5 application in iPhone 4.3.3

I am creating an iPhone project for iOS 5. I need to know if i can run the program in iPhone 4.3.3 and higher ?
Are you using anything in your code that was introduced with iOS 5.0 & newer? (such as storyboards)
If your answer is yes, then you can't run it on 4.3.3.
If no, then you can set the minimum required version to 4.3.X (and here's a tutorial you can use).
Here is a related question (and another one) that may help you out a bit more.
IIRC, you can configure the simulator in xCode to emulate an earlier version of iOS so you can confirm whether or not it will work on 4.3.3. Have a look at the build settings for your project, you can change the target O/S. I'm not sure all versions are available by default though. You might need to download other versions to test.
You said you are using ARC. ARC will work with iOS 4.x, but not iOS 3.x. So ARC will not be a problem. Based on everything else you said about not using storyboards and everything being coded, you should be okay. If you click on a method in Xcode it should allow you to bring up the documentation, and in the documentation it will provide the iOS version that it was released for. Make sure that this it iOS 4.3.3 or lower.

Xcode iOS SDK compatibility

How does the statement "The project should be compatible with iOS 4.0 and must run on iOS 4.3", effect the coding and judgment of Xcode version?
should be compatible with IOS 4.0
This means that you need to set your deployment target to 4.0 or lower. If you use any post-4.0 frameworks, they must be weak-linked, you cannot rely on them, and you must test for them before using them. Same goes for post-4.0 classes and selectors - you can't rely on them and you must test for them before using them. Simplest solution is simply to not use anything that isn't in 4.0.
must run on IOS 4.3
In general, everything that works on 4.0 will work on 4.3, so there's not much to worry about here.
Xcode version doesn't really matter. What matters is the version of the iOS SDK.
You can really use any version of the iOS SDK. Anything developed with any version of the SDK should be compatible with both 4.0 and 4.3.
If you need to use specific features of iOS 4.0 that are not available with previous versions, then you need to use 4.0 or later of the SDK.
In general, you should always use the latest version of the SDK, but set your target's properties to whatever the earliest version of the iOS is supported by your app.
It affects the earliest version of the OS (4.0) against you must test on an actual device.

(iphone) how can I tell I need a 3.0 + iOS installed device when looking at apple doc?

I've seen iphone related open source library which says something like,
"You need 4.0+ iOS build environment but the code will run on 3.0+ iOS device."
I wonder how those two requirements can differ and how can I tell a minimum 'device' iOS version which a certain api would need.
For instance I want to use UIGestureRecognizer but the apple doc says it's 3.2+, but I want my app run on 3.12+.
Is there a difference between build os requirement and device os requirement to run an app?
Thank you
Yes there is a difference. You can use a higher version of iOS to build an app targeted for a lower version of iOS (they are build settings, Base SDK & iOS Deployment Target respectively).
An example would be using the 4.0 iOS as your base sdk but setting your iOS Deployment Target to iOS 3.0, in this case if the compiler came across a function that is not supported for all iOS versions from 3.0 to 4.0 it will take that into account (i think its called weak linking).
If you know that there is a function that isn't going to work on versions of iOS that you want to support you can use something like this to stop that code executing:
if ( [anObject respondsToSelector:#selector(myFunctionForiOS4)] ) {
[anObject myFunctionForiOS4];
} else {
[anObject myFunctionForiOS3];
}

compiling iphone 3.1.3 with XCode 3.2.3?

I just downloaded XCode 3.2.3 with iphone sdk 4, but I need to compile my app with 3.1.3, but there is no option in the project settings for that (just 4.0 or 3.2). Is there any other possibility for me besides downgrading to XCode 3.2.2??
In the Deployment section of the Build settings, there is an option to set iPhone OS Deployment Target. You can choose 3.1.3 from the list of available OS versions.
Yes, you may choose any iPhone OS
Deployment target from the list. But
make sure that you are not using any
iPhone SDK 4.0 specific
methods/properties.
That is the catch, isn't it... is there an easy way to check that we're not doing any iOS4 SDK calls if we cant trap it during a compile?
I found this (see the bottom of the page):
http://0xced.blogspot.com/2010/07/using-sdk-313-with-iphone-sdk-4.html
Unfortunately, it requires the following on the first step:
"Locate iPhoneOS3.1.3.sdk and iPhoneSimulator3.1.3.sdk from an iPhone SDK 3 installation"
And, of course I blew away my iPhone SDK 3 installation when I installed the iOS 4 SDK. So I'm kinda stuck.
Is there another alternative?
Thanks!
Yes, you may choose any iPhone OS Deployment target from the list. But make sure that you are not using any iPhone SDK 4.0 specific methods/properties.
I strongly recommend you read this. SDKs other than 3.2 and 4.0 are no longer available for App Store submission.