You can use the Available tag, for example:
@available(*, deprecated) func myFunc() {
Where * is the platform (iOS, iOSApplicationExtension, macOS, watchOS, tvOS, * for all, etc.).
You can also specify the version of the platform with which it was introduced , deprecated , obsoleted , renamed and message :
@available(iOS, deprecated:6.0) func myFunc() { // calling this function is deprecated on iOS6+ } Or @available(iOS, deprecated: 6.0, obsoleted: 7.0, message: "Because !") func myFunc() { // deprecated from iOS6, and obsoleted after iOS7, the message "Because !" is displayed in XCode warnings }
If your project is focused on several platforms, you can use several tags, for example:
@available(tvOS, deprecated:9.0.1) @available(iOS, deprecated:9.1) @available(macOS, unavailable, message: "Unavailable on macOS") func myFunc() {
See the Swift documentation for more details.
Axel Guilmin Aug 20 '14 at 13:40 2014-08-20 13:40
source share