Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift3 Linux vc Mac DispatchQueue

According to swift.org/migration-guide, dispatch and related functions have a great new swift interface (e.g. dispatch_async -> DispatchQueue.async). Also other foundation types have been added like Data and Date value types instead of NSData and NSDate.

However, on the open source version of swift3 (developer preview 1) on linux, ubuntu15.10 the compiler rejects all of these changes. In fact, looking at the open source version of swift and swift-corelibs on github, I don't actually see any of these changes. Since it will compile on XCode developer preview, this has lead me to believe either: I am doing something wrong on Linux or these changes have been made in the Apple branch and not the open source branch. Can anyone verify this and if the latter is the case, and if so, how do we know what changes will be in the Apple branch vs the open source branch?

like image 657
slessans Avatar asked Jun 20 '16 17:06

slessans


2 Answers

As of Swift 3.0 release version GCD is available on Linux with simple import Dispatch, which is slightly confusing as it's not needed on iOS/macOS, where Dispatch module is imported by default.

like image 145
Max Desiatov Avatar answered Oct 21 '22 09:10

Max Desiatov


Thanks to Brad Larson for finding the Foundation and Dispatch overlays in the source. According to swift.org:

SDK Overlays: Specific to Apple platforms, the SDK overlays (implemented in stdlib/public/SDK) provide Swift-specific additions and modifications to existing Objective-C frameworks to improve their mapping into Swift. In particular, the Foundation overlay provides additional support for interoperability with Objective-C code.

tl;dr anything in these folders are Apple platforms only. Still not sure why they restricted the Dispatch overlays to Apple Platforms since libdispatch is also open source and targeting linux, but this answers my initial question.

Edit: was able to confirm via swift mailing lists that the dispatch overlays do have some reliance on objective-c runtime. There is work to get them implemented for non-Darwin platforms but no guarantees on timing.

like image 20
slessans Avatar answered Oct 21 '22 09:10

slessans