13

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?

Martin Bayly
  • 2,413
  • 3
  • 19
  • 19
  • I'm not seeing any warning either when running code for sdk 4.0+ and a deployment target of 3.0. This completely defies the documentation you stated above. Did you have any progress? – Oded Ben Dov Jul 20 '11 at 12:41
  • Just check mattjgalloway response here http://stackoverflow.com/a/8919108/536308 – ıɾuǝʞ Dec 04 '12 at 10:34
  • Possible duplicate of [Is there a way for XCode to warn about new API calls?](http://stackoverflow.com/questions/4676000/is-there-a-way-for-xcode-to-warn-about-new-api-calls) – JosephH Apr 05 '17 at 09:00

3 Answers3

3

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

Pol
  • 3,848
  • 1
  • 38
  • 55
  • Stellar link, @Pol! The graphic on the page illustrates the relationship quite well; could we include it here as part of this answer (with full credit, of course)? – big_m Feb 19 '13 at 01:27
2

temporarily change your base sdk to see them

justin
  • 104,054
  • 14
  • 179
  • 226
  • I thought of that as an option too, but I only have 4.2 installed. So I thought I'd try to download 4.0 to try this solution, but I don't seem to be able to find any reference to download the 4.0 SDK from apple.???? – Martin Bayly Jan 14 '11 at 16:39
  • you either install multiple sdks from the xcode installer, or (if that's not an option) install an additional version of xcode. the update frequency is very high on iOS, but not bad on OS X. i have two on the portable, and three on the power mac - that's almost as minimal as is possible for a ft developer. – justin Jan 15 '11 at 00:32
  • Ohhhh my god ! It's just incredible. So what is the use of that deployment target param ? Just to show it onto iTunes ? – Oliver Sep 04 '11 at 09:15
0

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:

  1. Login into your dev account and search API diffs. These official API diffs documents should be thorough and helpful.
  2. 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.

alt text

alt text

Di Wu
  • 6,436
  • 3
  • 35
  • 51
  • 1
    I've tried doing a clean build and that doesn't seem to change things. Just to clarify, it's not deprecated APIs I'm concerned about. It's where I've used an API that has been introduced in a version later than the iOS deployment target. I'm trying to determine my minimum iOS deployment target based on the APIs I've used. – Martin Bayly Jan 14 '11 at 06:25
  • Sorry for misunderstanding your problem. See my edited answer. – Di Wu Jan 14 '11 at 07:04