Should sdk = deployment target? - ios

And what will happen if it's not the case.
This may seem like an easy question.
Say base sdk is 5. Why can't it run on ios 7? What? Ios 7 can't run stuff built with base sdk 5?
So is it true that base sdk must be bigger or equal deployment target? If so why?
What would be the plus and minus if the 2 numbers are different?
I am looking for answers that answer:
1. Bad things happen if sdk > deployment target
2. Bad things happen if deployment target < sdk

From Apple
Choose a deployment target. This identifies the earliest OS version on which your software can run. By default, Xcode sets this to the version of the OS corresponding to the base SDK version and later.
And
Choose a base SDK. Your software can use features available in OS versions up to and including the one corresponding to the base SDK. By default , Xcode sets this to the newest OS supported by Xcode.
Your Xcode will likely only have a base SDK option of whichever is the latest iOS version it knows about (6.1 for Xcode 4.5, 7 for Xcode 5). That lets you use the newest features.
Say base sdk is 5. Why can't it run on ios 7? What? Ios 7 can't run stuff built with base sdk 5?
Nonsense, it can run on iOS7. And it will run on iOS8 when that comes out. It just can't use features that didn't exist yet.
So is it true that base sdk must be bigger or equal deployment target? If so why?
Xcode let me set base < deployment, but I don't see why you'd want that, or if it would actually run.
What would be the plus and minus if the 2 numbers are different?
Advantage: you can run your app on older devices.
Disadvantage: you have to make sure that you only call APIs that exist on the current version. Meaning, if you use iOS6-only features, you have to detect that you're running on iOS5 and not use them.

Related

What does deployment target mean?

this is a very simple question I'm assuming. Can someone tell me what deployment target means. If I choose IOS 10, does that mean only users with iOS 10 can download the app. Is it bad to choose a lower deployment target? ALSO, continuing on deployment target, is it not recommended to run on a lower deployment target.
Lets say you have set minimum deployment target to iOS 9.
This means your application is compatible for iOS 9 and above devices.
The application won't run on below 9.0 devices but can run on any iOS version greater than iOS 9.0.
The deployment target determines your app's ability to run on older iOS versions.
App with deployment target set to 10 will work on iOS version 10+ (10, 11, 12, 13 ...) but won't work on 9.x.
When a new version of iOS is released, some people do not bother to update their devices to the latest iOS version and thus they can't download your app from the App Store.
Example
If you choose higher deployment target (e.g 12.1), your app won't be able to download for the people who even have latest devices but have older iOS version (iPhone X with 11.0). In Contrast If you choose lowest possible deployment target (e.g 6.0), you try to make your app maximum backward compatible (so even if someone hasn't updated their iOS in ages will be able to download your app).
CAUTION
Many (almost all) newer frameworks and features won't be able to run properly (Behave as expected) on lower iOS versions which increases the chances of app crashes.
What Affects Deployment Target
Following are few factors that demands higher deployment target.
1) Using latest iOS SDK (alone)
2) Using latest iOS SDK specific features (Constraints, newer XIB files etc).
3) Using fast adapting external libraries / Frameworks (e.g Facebook SDK, Firebase etc).
4) Higher Swift Version (5.0) requires higher deployment target vs writing your app in legacy Objective C) !Needs citation.
SOLUTION
We have been using Deploymate for maximum backward support. It mainly assists us about warning the following:
1) Newer APIs that won't work on lower iOS versions
2) Using deprecated methods that won't work on newer iOS versions.
This is when you start fixing your code to make it available for lower iOS versions for maximum compatibility.
Note: Xcode also informs about several pitfalls. Deploymate is neither associates with us or pay us in any form. You can look for other alternates.
iOS Deployment Target(IPHONEOS_DEPLOYMENT_TARGET)
Deployment Target is a minimum version of iOS which is supported by your target.
It means that:
as a developer you support this version and you are able to support all next compatibility
as a user you should have at least this version of iOS
To change it in Xcode 11.5
Build Settings -> iOS Deployment Target
//.pbxproj
IPHONEOS_DEPLOYMENT_TARGET
If you are new to Xcode, I suggest accepting the default, and thinking of it as a constraint on your project.
As newer of Xcode versions come along, support for older target values will be removed. Companies that have extensive customer bases have to deal with this problem in their own way.
In most projects I have worked on, the iOS version matters because it dictates which devices can run your application.
For example, iOS 10 essentially left behind all iPod-style connectors.

XCode base SDK version in code

How can I get the version of the base SDK in code? I am currently building for iOS in XCode 6 and using the base SDK 8.1 . I would like to know if there is any define with the value of the SDK to be able to test it and allow building with different base SDKs.
You can find out the version of the current Foundation framework that the code is running against by checking the value of NSFoundationVersionNumber.
If you check out the NSObjCRuntime.h you will find the various version numbers listed in there.
As in regards to building against different versions of the SDK; Apple stops App Store uploads if you don't build against the latest SDK once the cut off date has come into effect - i.e. new apps submitted now must be build against iOS 8 SDK.
What you can however do, is have a lower iOS Deployment Target (this you can find in your project's settings). This will allow for your app to run on older iOS versions, but it will still be built against the latest SDK. Do note though, it is your responsibility to ensure that you do not use any new APIs without first ensuring the current environment supports them e.g. UITextField's selectable property.
If you call that whilst running on iOS 6, your app will crash.
This can be done using __IPHONE_OS_VERSION_MAX_ALLOWED (which is the same version as the base SDK version). That can be compared to __IPHONE_8_0 where 8_0 is the iOS release.
For example, at this point you can use the baseSDK 8.0 or 8.1.

How does an app with lower base sdk work?

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

targeting iOS5 - will it work on iOS6 also?

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.

XCode deployment target iOS 6 = compatibility to?

I seem to be not understanding the effects of a specific deployment target in XCode (4.5) correctly. Specifically, I got an app in the app store that was previously set for deployment target 5.0, meaning on the app store page it says "requires iOS 5.0". So when I now set the deployment target to 6.0 in my next update, does that mean it'll require iOS 6 and otherwise won't start? I'm not using new iOS 6 features in my update.
I guess that means I should stay at 5.0 for my deployment target, but then what is the point of changing your deployment target (provided the one you had used previously is not totally obsolete)?
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.
So when I now set the deployment target to 6.0 in my next update, does that mean it'll require iOS 6 and otherwise won't start?
Yes, if your deployment target is iOS 6, then users will need iOS 6 or above to run it. Simple as.
Your deployment target is your baseline for supported devices, it's the minimum version you support. This doesn't mean you can't use iOS 6 specific features, but it does mean you need to take into account iOS 5 users at runtime (See iOS SDK Compatibility Guide)
What developers typically do is update their base SDK. This means they're able to take advantage of the latest abilities of the SDK, to make a better user experience for users on that iOS version. Having a base SDK of iOS 6 does not mean the app won't work for iOS 5 users.

Resources