How to silence a warning in swift

Antzi picture Antzi · Jul 21, 2015 · Viewed 28.8k times · Source

I have a piece of code which is generating lots of warnings (deprecated API)

Using clang* I could do

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
    ...
#pragma clang diagnostic pop

However this does not work in swift.

How to do it in swift ?

Note: I don't want to disable the warning globally, nor even file wide, but just disable a specific warning in a specific part of my source code.

Edit: I looks like my note was not clear enough: I do NOT want conditional compilation (which is the proposed answer of the supposed duplicate). I just want to silence a warning WITHOUT using the new APIs.

Answer

Antzi picture Antzi · Sep 30, 2015

As of 2020, Xcode 12.0, the consensus is that there is no way to achieve that.

I'll update/edit this answer if Apple add the feature.

Put it in your wish list for WWDC 2021 !