Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get xcode 4.5 to warn about new API calls

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?

like image 980
moinudin Avatar asked Sep 28 '12 02:09

moinudin


People also ask

How do I remove unused APIs in Xcode?

Alternatively, enable the managed linker to remove unused APIs, including (in most cases) the new ones which require the specified library. However, this will not work if your project requires APIs introduced in a newer SDK than the one your Xcode provides.

How do I fix the Xcode SDK is not available error?

The recommended way to fix this error is to upgrade Xcode to get the needed SDK. If you have multiple versions of Xcode installed or want to use an Xcode in a non-default location, make sure to set the correct Xcode location in your IDE's preferences.

Why can't I launch an iOS app on Xcode 7+?

MT1027: Can't use Xcode 7+ to launch applications on devices with iOS * (Xcode 7 only supports iOS 6+). It is not possible to use Xcode 7+ to launch applications on devices with iOS version below 6.0. Please use an older version of Xcode, or tap on the app manually to launch it.

How to test asynchronous code in Xcode?

To test asynchronous code in Xcode we can use expectation and waitForExpectation function to be fulfilled within the specified timeout we pass. After the expectation is fulfilled a completion handler will be invoked that we can use to assert the result of the fulfilment from the asynchronous code.


1 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.

like image 173
borrrden Avatar answered Sep 21 '22 17:09

borrrden