[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 23:53:00 CDT 2016


Glad to know it. Thank you, Jack.

Zhaoxin

On Mon, Sep 26, 2016 at 10:17 AM, Jack Lawrence <jackl at apple.com> wrote:

> The API Reference SDK availability section in the documentation is
> incorrect for symbols defined in a Swift overlay. This is a known issue.
>
> Unless it has an explicit @available attribute (check the generated
> interface), any symbol defined in a Swift overlay is available for all
> platform versions where swift 3 is compatible (iOS 7, macOS 10.9, etc).
>
> Jack
>
> On Sep 25, 2016, at 6:01 PM, Zhao Xin via swift-users <
> swift-users at swift.org> wrote:
>
> 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 SDKs.
>    - *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.
>
> Data.init(base64Encoded:options:)
> <https://developer.apple.com/reference/foundation/data/1780388-init>
>
>> 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?
>
> Zhaoxin
>
>
> _______________________________________________
> swift-users mailing list
> swift-users at swift.org
> https://lists.swift.org/mailman/listinfo/swift-users
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160926/05c5dd9d/attachment.html>


More information about the swift-users mailing list