I couldn't find in Apple's documentation (Cocoa Auto Layout Guide) what is the lowest iOS version that supports this feature, nor any posts related to iOS... maybe it only depends on Xcode version, and not on iOS version? I need to develop an iOS app that should be compatible from the latest iOS version down to 4.3
Thanks
One way to find this out quickly is to set the deployment target of the XIB/Storyboard file directly. By default, it's set to the latest SDK version. Open the XIB/SB, and in the File Inspector (right panel), choose 4.3 (or whatever you like) as your deployment target.
If Auto Layout is enabled, Xcode will show an "Illegal Configuration" error for that file:
As you can see, it's iOS 6+ only. Auto Layout uses new APIs at runtime, so using the latest Xcode version does not help, and you cannot use Auto Layout conditionally in a XIB. You could, however, have separate XIBs for different system versions, but it sounds like a lot of (maintenance) work.
Setting the correct deployment target has another benefit: You will be warned if you use classes that have been introduced later than your deployment target.
Autolayout was introduced at WWDC 2012 and is supported starting on iOS 6. It'll definitely not work with iOS 4.3.
I strongly recommend you to think about if you really need to support iOS 4.3 these days. We're probably very close to have iOS 7 now and you'll be years behind (technologically speaking) supporting iOS 4.3. I understand apps that are currently supporting iOS 4.3, but I don't think it's a good idea do start developing an app now with iOS 4.3 support in mind.
Related
In XCode I can specify Base SDK. I am wondering how does that work behind the scenes? If I am running an app, for example, on a device that has iOS 7 and my base SDK is iOS 6, then how come the app has the old 'look and feel'? Does XCode compile the older SDK and include it within my app or does new version of iOS comes with older libraries/SDKs?
In other words, does the run time know this app is compiled with lower base SDK and somewhere in UIKit's code it does:
if (lower SDK) {
//show old look/feel
} else {
//show new look/feel
}
or does the app itself include the old library and load it ?
Thanks
iOS applications are forward compatible with new versions of iOS. The reason is :
Almost all changes to the iOS versions are additive and hence an
application build using lower version still runs on the higher iOS
version.
Though, we need to take care of this point:
As frameworks evolve through various releases, APIs are introduced or
deprecated and behaviors of existing APIs may occasionally change.
Apple makes every effort to minimize changes that may cause
incompatibilities, in some cases providing alternate behaviors based
on the framework version. In rare cases, your code needs to determine
the framework version and adjust accordingly
To understand more, read this
Apple never changes / deletes / renames classes or methods. They only add new ones.
If they don't want you to use it anymore, they mark it as deprecated.
This is a very important point.
At compile-time, the compiler checks if all classes and method signatures are available in the SDK your building your app with.
If that's the case, you can build and deploy your app. Because those classes and methods will never be deleted from newer versions of the framework, your app will run just fine.
On the other hand, you can build apps and deploy them to systems, which do not actually support the current SDK. For example, you can use Autolayout (NSLayoutConstraint class is available since 10.7) and deploy it for Mac OS X 10.6. The compiler will not say a word.
The app will crash though on systems prior to 10.7.
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
Your project is built against the Current SDK. If you have an older Deployment Target, then your code base is compiled against that. So if you are building against 7.0, but have a 6.0 deployment target, iOS 7 specific deprecations will not be triggered. Everything will be compiled against the oldest specified deployment target.
This will however put the pressure on you as a developer to make sure you are not using iOS 7 specific code. The compiler will still assume you mean to allow newer users to run your application as well and that all the newest methods are available to you and your latest version users. You can either test your code base against the older SDK with older devices or Simulators to make sure it runs well, or use an application like Deploymate that will test for methods you are using that could potentially cause problems.
If you plan to use any of the latest methods, you will need to wrap them up in the compiler if statement (like Peter Fidemraizer answered) or in normal if statements checking the version in the Foundation framework.
if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1) {
// Load resources for iOS 6.1 or earlier
} else {
// Load resources for iOS 7 or later
}
Base SDK means, the SDK that your app is going to be built on. SDK's have some frameworks etc. that are differantiated as the version of the SDK changes. For example;
Let's say your current Base SDK in your XCode is iOS 6:
You can have the frameworks and feautres that iOS 6 SDK provided you to.
Your app will be usable in any iOS SDK that you specify as "Minimum iOS SDK". Minimum iOS device gives you some restrictions on components to use. be aware of that.
Your app will be usable in iOS 7 too, just like it works in iOS 5 or iOS 6. Because iOS versions have backward compatibility. That means, iOS 7 will run the apps that are running in iOS 6 too.
Let's say your current Base SDK is iOS 6 and you want to make it iOS 7
Your app will be built with a brand new SDK, so, if the new SDK has
some big changes in it, you will see the differences immediately when
you run the app. For example, in iOS 7 SDK, you can use status bar
(20 px) as a view component too. That may ruin your view hierarchy.
You need to test your app again to check that your code is compatible with iOS 7
If you want to use new iOS 7 frameworks or features, you are in the correct way, you can use them now :)
In short, Base iOS SDK is on what iOS version your app is compiled & built on. running it on a iOS X? device is a different concept.
Hope this helps
Base SDK is the SDK that you want to use to build the app. Use "Deployment target" to specify the minimum OS you want your app to run on.
If you want to know the iOS version, check out this question.
While updating the Apple frameworks itself,Apple takes care of support for multiple iOS versions;However you need to follow some basics checks, which are explained here
How is it possible to use your pre-iOS 7 look and feel for your app? I just upgraded to iOS 7 and I have some apps on the phone that are still using the pre-iOS 7 look and feel. For instance one app is using the old UIPickerView look but it's running on iOS 7.
When I tested running the app that I am developing on the iOS 7 simulator it's using the new UIPickerView "automatically" without me doing any changes.
So I'd rather that my app uses the pre-iOS 7 look and feel until I have upgraded my app for iOS 7.
Here's an image of running Checkmark on iOS 7, you can clearly see it's using the pre iOS 7 keyboard:
That's rather simple: You have to build your app using the iOS6 SDK. iOS 7 detects older apps by checking the SDK against which the app was linked.
You can switch "Base SDKs" in Xcode by selecting the target, switch to the build settings tab, and find the "Base SDK" build setting under "Architecture".
If you don't have an older SDK you may need to use an older version of Xcode (4.6). Rob Napier describes here how to point a newer Xcode to older SDKs.
Note that while many UI elements retain their iOS 6 look, some don't (UIAlertView, UIActionSheet).
If you're using the standard UI components you're going to automatically get the new style on iOS 7, there's no way I've come across to force them to appear as they would in iOS 6. The only way you're going to be able to have them appear as iOS 6 elements is to build custom elements and style them yourself, however there's a risk in doing that that when you submit to Apple they'll reject on the basis of breaking the HIG.
On a device running iOS 7, all of the system UI—such as alerts and notifications—uses the iOS 7 appearance, even if your app is currently using an earlier appearance.
From Apple transition guide:
https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/TransitionGuide/SupportingEarlieriOS.html#//apple_ref/doc/uid/TP40013174-CH14-SW1
Not only do you need to build your app using iOS 6 SDK or earlier, you need to use Xcode 4.6 or earlier. I just went through all of this and targeting iOS 6 SDK from Xcode 5 is just not enough.
Luckily you can dual install both versions of Xcode. Just download Xcode 4.6 and drop it in your Applications Folder and rename is to something else
Hello I am beginner with these things and would appreciate nice explanations
that would dismiss my doubts.
If I target my app for iOS 5 -- does it mean users who have iOS 6 and iOS 7 can
also use it? Anything I should watch out for?
There are two primary settings used for your targeting your builds:
Base SDK & Deployment Target.
The Base SDK = What are the latest features I want available in this app?
The Deployment Target = What is the earliest OS I want to be able to run this app?
So, if you have both of these set to iOS 6, the user must have iOS 6 to install or run the app.
If you have a Deployment Target of iOS 5.0 and a Base SDK of 6.0 that means it'll install and run in iOS 5.0, but you need to be careful to branch your code and not use any iOS 6.0 features if the user is running on an iOS 5.0 device.
Yes, the target is the minimum version version that the app can run on. That doesn't mean that the app will work properly on newer versions and you really need to test to be sure. If you're creating a new app think carefully about which older versions to support.
If you target your Application for a lower iOS version, anyone with the version number you target AND HIGHER and access the application. Anyone LOWER than the one you target will not be able to download and use the application.
Everything will work fine, however there are certain features that are only available in iOS6 and iOS7 such as UICollectionView is only available in iOS6 and above. Fortunately you can test the different OS's in the simulator, it will make you life easier and you will be able to see if your application breaks running a different OS.
Haven't been able to find an accurate response to this question on Apple Developer forums.
As with other Apple Developers, I will upgrading our apps to support iOS6 devices.
I've downloaded XCode 4.5 which supports iOS6 SDK.
I understand I cannot submit versions of my app to the app store using this XCode build, however:
if I re-compile and build an app using the deployment target of 6.0 and fix all the known issues e.g. deprecated methods etc. when Apple releases GM for iOS6, will any build compile and work with iOS5 devices as well?
Should I just be submitting apps with a deployment target of 5.0 or will those fail to run in iOS6?
Should my deployment target only be iOS6 if I am using new iOS6 features?
(confused).
Since this is a pretty generic question about supporting multiple versions of iOS and does not cover any iOS6 specific things (covered by NDA), here goes my answer:
if I re-compile and build an app using the deployment target of 6.0 and fix all the known issues e.g. deprecated methods etc. when Apple releases GM for iOS6, will any build compile and work with iOS5 devices as well?
In principle, yes, it will, provided you have not used any iOS6-only feature or you did it properly (see the answer to your third question). However, testing against an actual device running iOS5/4 (or the simulator) is almost mandatory if you want to be sure that things work correctly.
There is also a chance that something that is currently working under an older iOS version will just break on iOS6 (this can happen in case some bugs were added, but also in case some bugs were fixed and it happens that your code had a bug of its own that countered the effect of the former). So, testing is the king. (Thanks to rsswtmr's comment about this).
Should I just be submitting apps with a deployment target of 5.0 or will those fail to run in iOS6?
You can specify a deployment target of 5.0 if your app does no use any iOS6-only feature (or you do it properly, read later); in other words, this setting will not break compatibility with iOS6;
Should my deployment target only be iOS6 if I am using new iOS6 features?
It can, but it is not the only way.
If you specify your deployment target as iOS6, then you can freely use any iOS6-only feature in your app without concern. The app store mechanics will prevent your app from being installed on any older device and you will be safe.
On the other hand, if you specify your deployment target as iOS5 or older, then you can still use any iOS6-only feature in your app, but you should properly support older versions of iOS by "guarding" any usage of iOS6-only features and providing a fallback for iOS5.
This means the following: say that you are going to use featureA only available on iOS6; what you can do is:
check to see if the feature is available at runtime (e.g. class respondsToSelector, etc);
guard your code within an #ifdef so that it will be compiled only on when possible;
if the check at 1. will fail, define a way out for older iOS versions.
Have a look at this post on supporting multiple iOS versions.
Set "Base SDK" to Latest iOS and "iOS Deployment Target" to the older version you plan to support (iOS 5.0 for instance).
Add conditional code to use feature available in latest iOS without crashing in the old one supported.
The section "Conditional Coding" in this Apple guide can be helpful. Also check other questions on the subject in SO.
I am in a process of learning ios development. I am beginning to learn storyboards and i found out that its only IOS 5 compatible. I searched here and found some answers but i wanted to find out if it make sense at this point to use storyboards. How does application behave that requires 5.0 in the app store? Does it show up for people that have 4.3 and lower? When i look through new application i don't see any that says 5.0 required in the description. Does that mean most people do not use storyboards to develop apps yet?
Thanks in advance!
story board is available in SDK 4.2 with which you can build for iOS 5, you can certainly set your deployment target to 4.x and it will work like a charm..!!
Updated : as #FirozeLafeer told, I confirmed my knowledge that he is right - XCode displays a message that "storyboards are unavailable on iOS 4.3 or prior"
From Apple: Storyboards are supported in iOS 5 and later and are enabled by default for new projects. If your app must run on earlier versions of iOS, though, you cannot use storyboards and should continue to use nib files.
Source: https://developer.apple.com/library/ios/#documentation/iphone/conceptual/iphoneosprogrammingguide/AppDesignBasics/AppDesignBasics.html