The answer to this question does not appear to work on xcode 4.5. To summarise it, is there a way for XCode to warn about classes, methods and procedures that are only available a later version than the deployment target?
2 Answers
There is a correct answer inside of the question that you linked too. With some experimentation, I came up with this (from mattjgalloway's answer):
#define __AVAILABILITY_TOO_NEW __attribute__((deprecated("TOO NEW!"))) __attribute__((weak_import))
#if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_6_0
#undef __AVAILABILITY_INTERNAL__IPHONE_6_0
#define __AVAILABILITY_INTERNAL__IPHONE_6_0 __AVAILABILITY_TOO_NEW
#endif
Then repeat for all the versions that make sense (i.e. 4.3 and above for Xcode 4.5). The __IPHONE_OS_VERSION_MIN_REQUIRED
macro will check the deployment target.
-
+1 for such a brilliantly filthy precompiler hack. Repeat the body of this for iOS 5 and iOS 6 warnings if you're an unfortunate sod who still has to support iOS 4. Dec 10, 2012 at 1:08
-
Very nice. It doesn't warn against everything, though. If I have Autolaypout turned on in my XIBs, there will be a runtime crash on an old SDK.– JeffJan 30, 2013 at 20:53
-
Sadly, it does not warn for everything. I get a warning for
ABAddressBookCreateWithOptions
but not for(NSString *)capitalizedStringWithLocale:(NSLocale *)locale
which are both new in iOS 6.0.– and3rsFeb 27, 2013 at 9:16 -
Not working for me in Xcode 4.5.2; it doesn't warn about -application:willFinishLaunchingWithOptions: when deploying to iOS 5.1 (base SDK is "latest"). Apr 17, 2013 at 19:53
-
1
This tool can do the job of finding too new API calls in your project: http://www.deploymateapp.com/