SlideShare a Scribd company logo
June 1, 2016
Open-Source Swift: Up and Running
Swift<Austin>() -> [Meetup][0]
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.
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
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.)
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)
Containers all the way down…
✤ We’re going to talk through a couple of options:
✤ Docker
✤ Vagrant
✤ I’m sure there are others
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
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
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)
Installing Docker
Mac or Windows
https://www.docker.com/products/docker-toolbox
Docker commands
docker run -it -v `pwd`:/Project swiftaustin-docker-swift ls /Project
docker build -t "swiftaustin-docker-swift" .
Vagrant
✤ Free VM software
✤ Build from spec file
✤ I tend to use this for development/debugging, and then move to Docker for
deployment
InstallingVagrant
Mac or Windows
https://www.vagrantup.com/downloads.html
Vagrant commands
vagrant ssh
vagrant up
Options and such are specified in vagrantfile
vagrant stop
vagrant destroy
June 1st, 2016
“Hello,World”
Really simple program with Docker and Vagrant configs and instructions https://github.com/SwiftAustin/HelloWorld
Vagrant “Hello,World”
start with: git clone https://github.com/SwiftAustin/HelloWorld.git
then: cd HelloWorld
run: vagrant up
then: vagrant ssh
then: cd /Project && swift build && ./build/debug/Project
Docker “Hello,World”
start with: git clone https://github.com/SwiftAustin/HelloWorld.git
then: cd HelloWorld
run: docker build -t "swiftaustin-docker-swift" .
then:
docker run -v ${PWD}:/Project swiftaustin-docker-swift 
bash -c 
”cd /Project && swift build && .build/debug/Project"
✤ swift build command expects a particular directory structure:
✤ Package.swift
✤ Sources/
✤ main.swift
✤ Tests/
✤ LinuxMain.swift
Swift Package Manager:A Brief Introduction
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>
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
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()

More Related Content

PDF
Swift 2.2 Design Patterns CocoaConf Austin 2016
PDF
Vagrant: The ability to create production environments from day 1 of development
PDF
Vagrant - the essence of DevOps in a tool
ODP
Grails Internals Ggug Dec 2009
PDF
Scalable Deployment Architectures with TYPO3 Surf, Git and Jenkins
PDF
GR8Conf 2015 - Spring Boot and Groovy. What more do you need?
PPTX
TYPO3 CMS deployment with Jenkins CI
PDF
Golang for PHP Developers: Dependency management with Glide
Swift 2.2 Design Patterns CocoaConf Austin 2016
Vagrant: The ability to create production environments from day 1 of development
Vagrant - the essence of DevOps in a tool
Grails Internals Ggug Dec 2009
Scalable Deployment Architectures with TYPO3 Surf, Git and Jenkins
GR8Conf 2015 - Spring Boot and Groovy. What more do you need?
TYPO3 CMS deployment with Jenkins CI
Golang for PHP Developers: Dependency management with Glide

What's hot (19)

PDF
TYPO3 Surf Introduction
ODP
Jenkins and rails app - Le Dinh Vu
PDF
Use groovy & grails in your spring boot projects
PDF
T3DD13 - Automated deployment for TYPO3 CMS (Workshop)
PDF
Openshift: Deployments for the rest of us
PDF
Bgoug 2019.11 test your pl sql - not your patience
PPTX
Dead-Simple Async Control Flow with Coroutines
PDF
5 Simple Tips for Troubleshooting Your Kubernetes Pods
PDF
Golang workshop
PDF
Node.js + influx + grafana
PPTX
Git hooks
PDF
Frida Android run time hooking - Bhargav Gajera & Vitthal Shinde
PPTX
Skaffold - faster development on K8S
PDF
OpenShift for developers in action! - jbcnconf19
PDF
Shift Remote: Mobile - Devops-ify your life with Github Actions - Nicola Cort...
PDF
Git hooks for front end developers
PDF
Enjoy privacy on Gitlab
PDF
Git hooks
PDF
Ci system part ii
TYPO3 Surf Introduction
Jenkins and rails app - Le Dinh Vu
Use groovy & grails in your spring boot projects
T3DD13 - Automated deployment for TYPO3 CMS (Workshop)
Openshift: Deployments for the rest of us
Bgoug 2019.11 test your pl sql - not your patience
Dead-Simple Async Control Flow with Coroutines
5 Simple Tips for Troubleshooting Your Kubernetes Pods
Golang workshop
Node.js + influx + grafana
Git hooks
Frida Android run time hooking - Bhargav Gajera & Vitthal Shinde
Skaffold - faster development on K8S
OpenShift for developers in action! - jbcnconf19
Shift Remote: Mobile - Devops-ify your life with Github Actions - Nicola Cort...
Git hooks for front end developers
Enjoy privacy on Gitlab
Git hooks
Ci system part ii
Ad

Similar to Open Source Swift: Up and Running (20)

PDF
Server(less) Swift at SwiftCloudWorkshop 3
PDF
Swift server-side-let swift2016
PDF
To Protect & To Serve
PDF
OpenStack Swift on virtualbox
PPTX
Server Side Swift
PDF
OpenStack Swift Command Line Reference Diablo v1.2
PDF
Swift Install Workshop - OpenStack Conference Spring 2012
PDF
Try! Swift Tokyo2017
PDF
server side Swift
PDF
Kubeflow Development Environment
PDF
Instruction: dev environment
PPTX
Swift at IBM: Mobile, open source and the drive to the cloud
PDF
Dockercon EU 2014
PPTX
The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...
PDF
Swift Buildpack for Cloud Foundry
PDF
Docker module 1
PDF
{py}gradle
PDF
Import golang; struct microservice - Codemotion Rome 2015
PDF
A Look at Command Line Swift
PPTX
Automate your Development Environments with Vagrant
Server(less) Swift at SwiftCloudWorkshop 3
Swift server-side-let swift2016
To Protect & To Serve
OpenStack Swift on virtualbox
Server Side Swift
OpenStack Swift Command Line Reference Diablo v1.2
Swift Install Workshop - OpenStack Conference Spring 2012
Try! Swift Tokyo2017
server side Swift
Kubeflow Development Environment
Instruction: dev environment
Swift at IBM: Mobile, open source and the drive to the cloud
Dockercon EU 2014
The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...
Swift Buildpack for Cloud Foundry
Docker module 1
{py}gradle
Import golang; struct microservice - Codemotion Rome 2015
A Look at Command Line Swift
Automate your Development Environments with Vagrant
Ad

More from Carl Brown (20)

PDF
GDPR, User Data, Privacy, and Your Apps
PDF
New in iOS 11.3b4 and Xcode 9.3b4
PDF
Managing Memory in Swift (Yes, that's a thing)
PDF
Better Swift from the Foundation up #tryswiftnyc17 09-06
PDF
Generics, the Swift ABI and you
PDF
Swift GUI Development without Xcode
PDF
what's new in iOS10 2016-06-23
PDF
Parse migration CocoaCoders April 28th, 2016
PDF
Advanced, Composable Collection Views, From CocoaCoders meetup Austin Feb 12,...
PDF
Gcd cc-150205
PDF
Cocoa coders 141113-watch
PDF
iOS8 and the new App Store
PDF
Dark Art of Software Estimation 360iDev2014
PDF
Intro to cloud kit Cocoader.org 24 July 2014
PDF
Welcome to Swift (CocoaCoder 6/12/14)
PDF
Writing Apps that Can See: Getting Data from CoreImage to Computer Vision - ...
PPT
Introduction to Git Commands and Concepts
PDF
REST/JSON/CoreData Example Code - A Tour
KEY
360iDev iOS AntiPatterns
KEY
Chipmunk physics presentation
GDPR, User Data, Privacy, and Your Apps
New in iOS 11.3b4 and Xcode 9.3b4
Managing Memory in Swift (Yes, that's a thing)
Better Swift from the Foundation up #tryswiftnyc17 09-06
Generics, the Swift ABI and you
Swift GUI Development without Xcode
what's new in iOS10 2016-06-23
Parse migration CocoaCoders April 28th, 2016
Advanced, Composable Collection Views, From CocoaCoders meetup Austin Feb 12,...
Gcd cc-150205
Cocoa coders 141113-watch
iOS8 and the new App Store
Dark Art of Software Estimation 360iDev2014
Intro to cloud kit Cocoader.org 24 July 2014
Welcome to Swift (CocoaCoder 6/12/14)
Writing Apps that Can See: Getting Data from CoreImage to Computer Vision - ...
Introduction to Git Commands and Concepts
REST/JSON/CoreData Example Code - A Tour
360iDev iOS AntiPatterns
Chipmunk physics presentation

Recently uploaded (20)

PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
Big Data Technologies - Introduction.pptx
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
cuic standard and advanced reporting.pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
PPT
Teaching material agriculture food technology
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Encapsulation theory and applications.pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Machine learning based COVID-19 study performance prediction
MIND Revenue Release Quarter 2 2025 Press Release
Digital-Transformation-Roadmap-for-Companies.pptx
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
The Rise and Fall of 3GPP – Time for a Sabbatical?
Building Integrated photovoltaic BIPV_UPV.pdf
Big Data Technologies - Introduction.pptx
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
cuic standard and advanced reporting.pdf
The AUB Centre for AI in Media Proposal.docx
Teaching material agriculture food technology
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Encapsulation theory and applications.pdf
Review of recent advances in non-invasive hemoglobin estimation
“AI and Expert System Decision Support & Business Intelligence Systems”
MYSQL Presentation for SQL database connectivity
Agricultural_Statistics_at_a_Glance_2022_0.pdf
NewMind AI Weekly Chronicles - August'25 Week I
Per capita expenditure prediction using model stacking based on satellite ima...
Machine learning based COVID-19 study performance prediction

Open Source Swift: Up and Running

  • 1. June 1, 2016 Open-Source Swift: Up and Running Swift<Austin>() -> [Meetup][0]
  • 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)
  • 10. Installing Docker Mac or Windows https://www.docker.com/products/docker-toolbox
  • 11. Docker commands docker run -it -v `pwd`:/Project swiftaustin-docker-swift ls /Project docker build -t "swiftaustin-docker-swift" .
  • 12. Vagrant ✤ Free VM software ✤ Build from spec file ✤ I tend to use this for development/debugging, and then move to Docker for deployment
  • 14. Vagrant commands vagrant ssh vagrant up Options and such are specified in vagrantfile vagrant stop vagrant destroy
  • 15. June 1st, 2016 “Hello,World” Really simple program with Docker and Vagrant configs and instructions https://github.com/SwiftAustin/HelloWorld
  • 16. Vagrant “Hello,World” start with: git clone https://github.com/SwiftAustin/HelloWorld.git then: cd HelloWorld run: vagrant up then: vagrant ssh then: cd /Project && swift build && ./build/debug/Project
  • 17. Docker “Hello,World” start with: git clone https://github.com/SwiftAustin/HelloWorld.git then: cd HelloWorld run: docker build -t "swiftaustin-docker-swift" . then: docker run -v ${PWD}:/Project swiftaustin-docker-swift bash -c ”cd /Project && swift build && .build/debug/Project"
  • 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()