I have some deprecated constants in my project. They need to stay. I don't want to be warned about them, but do want to be warned if other deprecated constants should turn up in my project later.
Apple's header declares them as follows:
extern NSString * const NameOfStringConstant __OSX_AVAILABLE_BUT_DEPRECATED(version availability info here)
How can I silence the warning?
Related answer for silencing the warning for a deprecated method here
Related answer for silencing the warning about a deprecated string conversion here
Add to the compiler flags:
-Wno-deprecated-declarations
or, in Xcode, select "No" for the build setting option:
Warn About Deprecated Functions
and then if you look at the build output (Apple+7 in Xcode 4), you'll notice the aforementioned compiler flag.
I know this is an old topic but today i was dealing with the same annoyance.
Example: you want to get rid of the annoying deprecation warning but just for [[UIDevice currentDevice] uniqueIdentifier]]
since you most probably want to use it in development phase with TestFlight.
You'd still want the compiler to warn you if you use some other deprecated declaration by mistake.
I like sarfata's answer: it does the job. But there's more politically correct way available:
Following recipe is taken from The Goo Software Blog.
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
[TestFlight setDeviceIdentifier:[[UIDevice currentDevice] uniqueIdentifier]];
#pragma clang diagnostic pop
Make sure you comment out this lines before building for distribution. Or simply use a preprocessor macro to exclude this lines from a release build.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With