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
Related
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.
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];
}
I'm building an iOS app using Xcode 3.2.5 with the Base SDK set to iOS 4.2
I know I've used some api's from 4.0 and 4.1 but not sure about whether I actually require 4.2.
According to the iOS Development Guide, "Xcode displays build warnings when it detects that your application is using a feature that’s not available in the target OS release".
So I was hoping to use the compiler warnings to derive my minimum OS requirement.
However, even when I set my iOS Deployment Target to iOS 3.0, I still don't get any compiler warnings.
I must be doing something wrong, but not sure what? Can anyone confirm that they get compiler warnings when the iOS deployment target is less than the base SDK and the code uses base SDK functions? Or do the compiler warnings only show if you link a framework that didn't exist in the iOS deployment target version?
It's behaving as expected: changing the deployment target only affects the minimum OS version you app will run on, not the maximum.
If you use the 4.3 SDK and set the deployment target to 4.0, it just means your app will hard-link any pre-4.0 APIs and weak-link any APIs introduced between 4.0 and 4.3. You have to check at runtime either for the existence of the API (e.g. null pointer for C functions) or the OS version.
The deployment target does generate Xcode warnings but for deprecated APIs: for example if you use an API deprecated in 4.1 and later and the deployment target is 4.1 or later, you get a warning, but if it's 4.0 or earlier, you don't.
It looks like what you really need in your case is the equivalent of MAC_OS_X_VERSION_MAX_ALLOWED (it's not part of the default build settings, but you can custom define it and it should override the value set by the SDK) but for iOS SDK. I'm not sure it officially exists actually: I was able to find a __IPHONE_OS_VERSION_MAX_ALLOWED but considering it starts with __, I'm not sure it's really supported.
The right solution appears to simply build against previous versions of the SDK (you can always do that in the Simulator) and you will get Xcode errors if using missing APIs.
For more info, read this technote: http://developer.apple.com/library/mac/#documentation/DeveloperTools/Conceptual/cross_development/Configuring/configuring.html
temporarily change your base sdk to see them
Edited: for detecting new APIs that are only available in new versions of iOS, I don't think Xcode can do it automatically for us. We need to put them in our mind by ourselves. My suggested reading source:
Login into your dev account and search API diffs. These official API diffs documents should be thorough and helpful.
Check this great post on how to wrap up your code to make it compatible on lower versions of iOS:
===
Try clean your project's build folder. After that you should see warnings on deprecated APIs that your code used.
i started a project with the iOS SDK 4.0 and want to use blocks in order to animate some UIViews. But after I recogized that "animateWithDuration" isn't available i updated my XCode and iOS SDK to 4.2. In my project I set the "base sdk" to 4.2, too.
I thought that might solve the problem. But XCode still complains about the missing method. Is this method not available for simulator builds? Or what do I have to do in oder to activate it?
Thx.
kie
Look in the project build settings for the Deployment Target setting. This is the lowest version of the SDK that you're interested in supporting. If it's lower than 4.0 then all of the pre-4.0 methods will be stripped out by the compiler (since they won't be available on the devices you're planning to deploy to). Try setting it to 4.0 or later; that should help.
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