[swift-users] Why API marked as `macOS 10.12+` can be used in macOS 10.11?

Zhao Xin owenzx at gmail.com
Sun Sep 25 20:01:11 CDT 2016

In the official migrating guide <https://swift.org/migration-guide/>.

You can choose from two kinds of migration to perform:

   - *Use Swift 2.3* Modifies your project to enable the *Use Legacy
Swift* build
   setting and provides source changes to be able to build against the new
   - *Use Swift 3* This is recommended. You will get source changes to be
   able to build your project using Swift 3 and take advantage of all the new
   features in Xcode 8.0.

Optionally, you can move to Swift 2.3 now and invoke the migration
assistant again later to update to Swift 3.

So it seems to me that Swift 3 will only works with the new SDKs (iOS 10,
macOS 10.12, watchOS 3, tvOS 10). The API explanation enhanced my theory.


> Language
> Swift
> SDKs
> iOS 10.0+
> macOS 10.12+
> tvOS 10.0+
> watchOS 3.0+

I created a new Cocoa application project in Xcode 8. Since my OS is macOS
10.11, the `Deployment Target` is `10.11`, the `Base SDK` is `10.12`. Since
the newly created project's swift version is default 3.0. I thought I
couldn't use any apis that were marked as `macOS 10.12+`. However, I was
wrong. Below code worked.

var data = Data(base64Encoded: "Hello World!")

print(data) // prints nil

So what are the boundary between old APIs with new APIs between OS
versions? Is the API doc wrong? In previous docs, if an API is marked
as available only in the latest OS, you can't use it in old OS. Is that
rule changed in Swift 3?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160926/036c8a46/attachment.html>

More information about the swift-users mailing list