Inaugural Meetup for the Swift Austin group. Introduction and how-to presentation on getting the latest (or recent) version of Swift running in a Docker or Vagrant VM under MacOS or Windows.
2. Slides will be posted
No need to try to write everything down.
I’ll post a link to the Meetup.com comments
for this meeting.
3. Please, STOP me at
your convenience
Swift is new
It is changing very quickly
We’re all learning this together
Please share your experience with us
4. Assumptions
✤ You want to be able to Compile/Run/Test/Learn “Pure” Swift
✤ That is: Swift without the closed-source Objective-C runtime (more on that later)
✤ You don’t want to have to build Swift and LLDB from scratch
✤ At least not at this meeting
✤ You aren’t running the Exact, Precise versions of Ubuntu (15.10 or 14.04) Apple Supports on
the machine in front of you
✤ (If you are, then the first part of the meeting won’t be necessary for you, please hang on
for a while.)
5. Prerequisites
✤ You need a specific version of Ubuntu (15.10 or 14.04)
✤ You need specific libraries installed
✤ You need specific executables installed
✤ And those might change at any (or every) snapshot
✤ … OR, of course, you can CHEAT (and probably should)
6. Containers all the way down…
✤ We’re going to talk through a couple of options:
✤ Docker
✤ Vagrant
✤ I’m sure there are others
7. Swift Roulette: Step Right Up & Pick aVersion
✤ Usually several versions to pick from on swift.org/download
✤ The current release version is there (but that’s OLD)
✤ Historically, we’ve gotten a new SNAPSHOT every couple of weeks or so
✤ But, we just got Swift 3.0 Preview 1, (YESTERDAY!!) so I don’t know how
that might affect the SNAPSHOT schedule
8. Swift Roulette: Step Right Up & Pick aVersion
✤ Tonight, I’m going to use the 3.0 preview 1
✤ And I’m going to do it via Docker/Vagrant
9. Docker
✤ Seems to be coming the de-facto standard (from what I can see)
✤ Has issues with development (especially debugging - more later)
✤ Easy to use for deployment
✤ (You can use "carlbrown/docker-swift:latest", as a base
✤ at least until the rest of the ecosystem catches up with the latest drop)
18. ✤ swift build command expects a particular directory structure:
✤ Package.swift
✤ Sources/
✤ main.swift
✤ Tests/
✤ LinuxMain.swift
Swift Package Manager:A Brief Introduction
19. Playing with the REPL
✤ from vagrant ssh
✤ swift
Welcome to Swift version 3.0-dev (LLVM 3863c393d9, Clang d03752fe45, Swift
e996f0c248). Type :help for assistance.
1>
20. REPL with Docker
✤ REPL (and debugger) require root access (to be able to attach to processes)
✤ If you forget, you’ll get:
✤ To type, you also need -it for interactive and tty
docker run -it --privileged=true -v ${PWD}:/Project docker-swift swift
error: failed to launch REPL process: process launch failed: 'A' packet returned an error
21. Differences from OS X
✤ No Objective-C runtime
✤ Many casts between object types just fail
✤ Many libraries that work on OS X explode on Linux (often at runtime)
✤ e.g. I can put an Int64 into a Dictionary, but passing to SwiftyJSON crashes
✤ Many parts of Foundation just aren’t there
✤ Embrace your inner NSUnimplemented()