Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Swift on Linux

Swift on Linux

Brief description of experience with writing program that works on Linux and MacOS

Avatar for Błażej Wdowikowski

Błażej Wdowikowski

June 28, 2017

Other Decks in Technology

Transcript

  1. 3 SWIFT ON LINUX What we will talk about Swift

    Package Manager and the environment What the program do Differences in Swift on Linux and macOS What Apple say about Swift port on Linux Is it worth to follow?
  2. 5 SWIFT ON LINUX Swift Package Manager and the environment

    import PackageDescription let package = Package( name: "Solam", targets: [ Target( name: "Solam", dependencies: ["ifaddrs"]), Target( name: "ifaddrs", dependencies: []), ], dependencies: []) #if os(macOS) package.dependencies = [ .Package(url: "https: //github.com/Anviking/Decodable.git", Version(0,5,1)), .Package(url: "https: //github.com/JohnSundell/Files", Version(1,9,0)) ] #elseif os (Linux) package.dependencies = [ .Package(url: "https: //github.com/JohnSundell/Files", Version(1,9,0)) ] #endif What the program do
  3. 6 SWIFT ON LINUX Swift Package Manager and the environment

    import PackageDescription let package = Package( name: "Solam", targets: [ Target( name: "Solam", dependencies: ["ifaddrs"]), Target( name: "ifaddrs", dependencies: []), ], dependencies: []) #if os(macOS) package.dependencies = [ .Package(url: "https: //github.com/Anviking/Decodable.git", Version(0,5,1)), .Package(url: "https: //github.com/JohnSundell/Files", Version(1,9,0)) ] #elseif os (Linux) package.dependencies = [ .Package(url: "https: //github.com/JohnSundell/Files", Version(1,9,0)) ] #endif What program do
  4. 7 SWIFT ON LINUX Swift Package Manager and the environment

    MacOS with Swift 3.1 Ubuntu 16.10, Swift 3.1.1 github.com/icanswiftabit/solam What the program do
  5. 8 SWIFT ON LINUX What the program do Get an

    internal IP address using C
  6. 9 SWIFT ON LINUX What the program do Read user

    input Get an internal IP address using C Make a sequenced HTTP request with GCD and URLSession Print proper messages into the console Deserialize JSON responses into structs Save output to a file with John Sundell's Files Get an internal IP address using C
  7. 10 SWIFT ON LINUX What the program do Get an

    internal IP address using C Read user input Get an internal IP address using C Make a sequenced HTTP request with GCD and URLSession Print proper messages into the console Deserialize JSON responses into structs Save output to a file with John Sundell's Files
  8. 12 SWIFT ON LINUX Get an internal IP address using

    C Constants AF_INET, AF_INET6 are UInt16 on Linux and UInt8 on macOS struct sockaddr on Linux doesn't have sa_len field GCD and URLSession
  9. 16 SWIFT ON LINUX JSON What Apple say about Swift

    port on Linux On macOS, I use Decodable and it is pretty straightforward kingdom for a JSON deserialize on Linux
  10. 17 SWIFT ON LINUX What Apple say about Swift port

    on Linux Swift is already ported to Linux
  11. 18 SWIFT ON LINUX Swift is already ported to Linux

    What Apple say about Swift port on Linux In the most part
  12. 19 SWIFT ON LINUX Swift is already ported to Linux

    Is it worth to follow? the GCD port was completed around May 20th random number generation some C structs are absent or only partially available some String APIs are missing due to NSString bridging on macOS some mechanisms that rely on Objective-C are missing
  13. 21 SWIFT ON LINUX Is it worth to follow? server-side

    projects, such as Perfect, Kitura and Vapor IoT, because you can use Swift on embedded systems scripting, of course Questions?