Swift is flagging the use of deprecated functions as errors

Using the __deprecated flag on an objective-c member causes the compiler to flag that as an error in swift code. Is there some other mechanism to flag something as deprectated and get a warning in swift rather than an error?

If you look at Apple's header files, it looks like they use the

NS_DEPRECATED
macro from NSObjCRuntime.h.


Does it have the same effect as __deprecated?

Seen this from the Xcoce 7 beta release notes?



Deprecations and Removal Notices

• OS X 10.11 is the last major release of OS X that will support the previously deprecated garbage collection runtime. Applications or features that depend upon garbage collection may not function properly or will not launch when the runtime is removed. Developers should use Automatic Reference Counting (ARC) or manual retain/release for memory management. (20589595)


I don't know if the previous response answered your question.


Check your project build settings under "Apple LLVM 7.0 - Warning Policies" that you do not have "Treat Warnings as Errors" enabled.

The ns_deprecated bits refer mostly to things that were deprecated in the various OS verisons rather than our client code. The "Treat Warnings as Errors" flag is off and the objective-c code compiles fine with the appropriate warnings. It is just the swift code that turns what should be a warning into an error. The note from KMT is a bit off the mark, it just refers to the fact that the compilers/OS will stop supporting non-ARC code after 10.11.


Problem we face is a very large project that we are trying to move some base bits forward so we want to deprecate some old functions and then when we get everybody to move all of their bits to the new stuff we'll kill the old code. Works great except for the more recently added Swift code which is using the old bits.

>it just refers to the fact that the compilers/OS will stop supporting non-ARC code after 10.11.

Actually, it screams current bugs/coming changes, which is dead on the mark, I think by confirming the problems you've alluded to. File them to let Apple know, as usual.

Interesting. Thank you for clarifying that ckhpdx. Yeah, it seems filing a bug would be appropriate.


Would be interested in knowing the appropriate way to indicate deprecation in Swift. I have also always used the __deprecated annotation in Objective-C code and have not had a need yet in my Swift code.

Using Xcode 7 beta, using __deprecated marks obj-c methods as "@available(*, deprecated)" in the generated Swift header.


I tried importing a Swift framework with a deprecated class and a deprecated method using "@available(*, deprecated)", and it only caused warnings in the Swift code.


It must work differently for Obj-C frameworks?

Swift is flagging the use of deprecated functions as errors
 
 
Q