warning if method availability is newer than minimum deployment target

Hi Richard, Hi Ted,

I just found this post in the archive and was wondering if this was still on your (or anyone else’s) radar? I absolutely agree with Richard in that I find it pretty inconvenient to find new APIs in projects with an older deployment target. If you use the Android SDK & tools, Lint will give you warnings for any APIs that are newer than your deployment target (it’s called minimum SDK there…). If you use them deliberately and only under certain conditions, you can add a @TargetAPI annotation to surpress the warning:


A similar behaviour should be fairly easy to add to Clang and would make it heaps easier to implement/ensure backward compatibility of iOS/Mac apps. As a matter of fact, I’ve made the topic of backward compatibility the subject of my diploma thesis and started hacking on Clang a few days ago and already see these warnings popping up.

An initial (very informal) survey on this issue revealed that app developers would appreciate such a feature and they’d prefer having the compiler issue the warnings with every build (with a command line option to disable the feature) rather than running the analyzer separately. For my first hacks, I started checking the API version in the methods of “SemaExprObjC.cpp”, although I can see that from a conceptial point of view, it’s probably not the best place…

I’m keen to hear your thoughts on that, and whether or not you are working on similar Clang features.


Hi Sebastian,

Richard has been doing some great work to try and wire up the necessary infrastructure to implement some (or all) of this warning in the static analyzer. My own goal is to try and make this a compiler warning at some point in addition to a static analyzer warning, since it will get the highest visibility among users. It’s much tricker to do as a compiler warning, given the performance requirements of the compiler and the tricks we will need to do to get the necessary accuracy which we get for free with the static analyzer. It’s a back burner project for me right now, but there is definitely interest in pushing this forward.