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 obsolescence warning, but only for [[UIDevice currentDevice] uniqueIdentifier]] , since you most likely want to use it at design time with TestFlight. You still want the compiler to warn you if you mistakenly use some other obsolete declaration.
I like the answer of sarfata : it does the job. But there is a more politically correct way:
The 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
Be sure to comment out these lines before creating them for distribution. Or simply use a preprocessor macro to exclude these lines from the release build.
source share