Methods from new iOS-version, not giving warning, dispite of older SDK - ios

I have a basic question about the difference between the "deployment target" and iOS version availability. By example:
In my project I use this line of code:
I Xcode i setup the project like this:
and it matches the deployment info under the specific target as well.
When I run this code, it works.! But why?
How come I don't get any warnings?
My deployment target is lower than the availability for that specific line. Why dosn't the compiler give me an error here? I'm testing the code on my iPhone with iOS 9.1 installed, is that why? The same thing happends when I run it on the simulator, also with iOS 9.1
EDIT:
After reading through the App Distribution Guide and SDK Compatibility Guide, I still dont get, why I'm allowed to run "MKMapSize"-method, when my base SDK is set to iOS 8.0, whitout getting any warnings? See image from target settings -> build settings:
EDIT 2:
I found an example of a new method that does give med the error I'm asking for:
Why does this method give me an error, when the 8.1 method doesn't give me an error?
EDIT 3:
So if I go along and uploads this project to the app store, will the app work for users running iOS 8.0? or will it crash when MKMapSize (which is available in iOS 8.1 and later) is executed?

MKMapSize was added in iOS 4 according to the documentation:
Availability Available in iOS 4.0 and later.
I too have noticed that the mouseover popup "lies" regarding the availability. It seems to use the version you're targeting and not the actual availability specified in the code, if the actual availability version is lower than your deployment target.
It's either a bug, or it might be because iOS 8.1 is the earliest SDK you have installed on your machine.

Related

How to solve iOS deployment target issue?

I am trying to run an application I am developing on an iPhone that runs iOS 10.2.1. I also tried to run it on a simulator that runs iOS 10.2. My Xcode version is 8.3.3. Even though I changed the deployment target to 8.0, I get the following error when I try to run it on a device under 10.3. Are there other things I should pay attention when changing the deployment target other than changing it from Info tab in Xcode? The error states the deployment target as 10.3 but it is not. How can I get around this issue?
"Run destination is not valid for running the scheme.."
My deployment target
Thank you,
I remember the same issue happening in my code.
In my case, I realized that I had not updated my Base SDK to the latest iOS version in the Build Settings
To do so, click on Project name -> Build Settings -> Base SDK
If Base SDK does not show, ensure that "All" is selected in the filter at the top of the page.
Also, sometimes the project has multiple targets and you might be setting the Base SDK on the wrong target.
You need to update your iphone to the newer version or downgrade your xcode version. Currently they are out of sync thus why you are seeing this error.
See here for compatibility:
https://developer.apple.com/library/content/releasenotes/DeveloperTools/RN-Xcode/Chapters/Introduction.html

Xcode's mechanism blocks latest build on older version iOS devices

The Xcode 6.3.2 has the compatibility from iOS 4.3. I run an application built with minimum deployment target with 6.0 and I try to run this application in iPhone with iOS lower than 6.0. When we do this, Generally Xcode prompts and saying, targeted device doesn't have the support kind of error.
What mechanism that Xcode and iPhone has to prompt the user by saying this incompatibility message.
This question seems to be meaningless. But, Just Wanted to know how the Xcode doing this? and with what mechanism?
If anybody has idea. Thanks in advance!!!
If you're deploying through the app store, the user won't be able to install it. It won't even show up in the search results for them.
It depends on the iphone ios version and the xcode Deployement target you set no matter what the base SDK is..

Macros in iOS to give warning if method used is not available on minimum supported version

Recently I updated my Xcode to 6.3(sdk iOS8). I am using one API of NSString called "containsString" which is available from iOS 8.0 onwards. But my deployment target is 7.0 and this API is not available on iOS7. App is running fine on iOS8, however it was crashing on iOS7 since it did not find that API.
Now ideally Xcode should have given me warning since the API is not available on deployment target (iOS7).
Is there a way to make xcode give warning or even build error if the API is not supported on minimum supported iOS version?
I would prefer if anyone has way to do it using pre compiled headers.
Try this:
"#warning" this will create a user defined warning and will be highlighted in yellow as a normal warning.
example "#warning warningMessage".

How Apple knows if an app only runs on 6.1 or above?

Just a small query :
When you develop the app, is it written somewhere in the code what iOS the app should run on?
We’re trying to determine how Apple knows if an app only runs on 6.1 or above.
Also – maybe you know for sure… if a user with 6.0 tries to download our app that requires 6.1 or above, what happens? And, if a user with 6.0 already has the app installed (but not the update for 6.1 or above) are they still able to open the app?
In respect to it being written in code, there is a preprocessor macro you can use to get the version you defined as the deployment target.
__IPHONE_OS_VERSION_MIN_REQUIRED
That'd return 60100 for 6.1 I believe. It seems that's not your question. Apple know because of the deployment target you set in the target general settings. If you set 6.1, then anyone below that can still run your app if they have it installed but cannot update or see newer versions.
A settings section is available in Xcode named as Base SDK . If this is 6.1, then app only runs on 6.1 or above. These informations are embedded with the binary you are uploading.
if a user with 6.0 tries to download our app that requires 6.1 or
above, what happens?
If you select the app you want in the App Store and, if it's incompatible with your iOS version, a prompt will appear offering to let you download a previous, compatible version of the app.

How to deal with Xcode update to recommend settings warning?

Recently, I upgraded to Xcode 6. Anything works well except I got a new warning indicates me to upgrade iOS Deployment Target to 8.0. Bellow is a screen shot of the message.
However, I don't want to upgrade deployment target because I want to support any device that has OS version 7.0 and above.
How to ignore this warning? Or perhaps iOS Deployment Target setting has nothing to do with the lowest OS version that my app can support?
I think there is a bit of confusion here, there is a difference between the Base SDK setting and the Deployment Target. Deployment target determines which versions of iOS you support, the SDK version simply determines which version of the SDK you are using to write your code. As long as you don't use any code which requires iOS 8 (Or if you want to use it check that it is available: Checking For Class Availability). So to fix this, you should click Perform Changes. You will still be able to run your app on iOS 7 :)

Resources