Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use xcode compiler warnings to determine minimum IOS deployment target

Tags:

xcode

ios

iphone

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?

like image 571
Martin Bayly Avatar asked Jan 14 '11 05:01

Martin Bayly


People also ask

How do I check my iOS deployment target?

Click the Books target and select the General tab at the top. The General tab contains a section with name Deployment Info. The section contains a dropdown menu and three checkboxes, iPhone, iPad, and Mac. Because I am using Xcode 12, the dropdown menu is currently set to iOS 14.3.

How do I change the minimum deployment target in Xcode?

To change your deployment target, open up your project file in Xcode and check the setting under Build Settings -> Deployment(...) Check this answer to add earlier devices support.

What is minimum deployment target iOS?

Do I need to change the Minimum Deployment Target because of the latest news in the Apple Developer News. Currently, the Minimum Deployment Target of my apps is iOS 10.

How do I change the minimum iOS version in Xcode?

iOS Deployment Target set to 14.1 or whatever version you want to be minimum inside the Project > Build Settings > Deployment for all instances. iOS Deployment Target set to 14.1 or whatever version you want to be minimum inside the Target > Build Settings > Deployment for all instances.


1 Answers

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

like image 157
Pol Avatar answered Oct 23 '22 03:10

Pol