Silencing deprecation warnings in Swift

Steve Christensen <punster@...>

I’m in the process of porting some Obj-C code to Swift. Several Core Data entity properties are marked as deprecated for general use but, at least in several migration methods, they still need to be accessed legitimately.

With Obj-C the code in specific methods is bracketed with #pragmas where the deprecated properties are accessed:

- (void) MigrateFoo
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations”

// touch deprecated properties

#pragma clang diagnostic pop

Note that I do not want the warnings silenced project-wide nor, ideally, for an entire source file.

Is there a way of doing this when compiling Swift? Older posts on stackoverflow, etc., mention that it wasn’t doable at the time, but I haven’t seen more recent mentions either way.