(iOS and Backend) • Faster/Easy to deploy (No VM and Interpreter) • Can reduce run-time errors with Strong Static Typing and Null Safety • Easy to handle parallelism and asynchronously (GCD) 1. Web Development with Swift
management system for Swift. • Post Carthage and CocoaPods • Use to configure application settings and manage dependencies (It’s like npm, sbt) • Also includes cross platform build system (llbuild) > 1. Development Environment 1. Web Development with Swift
swift package [options] subcommand SUBCOMMANDS: clean Delete build artifacts describe Describe the current package dump-package Print parsed Package.swift as JSON edit Put a package in editable mode generate-xcodeproj Generates an Xcode project init Initialize a new package reset Reset the complete cache/build directory resolve Resolve package dependencies show-dependencies Print the resolved dependency graph tools-version Manipulate tools version of the current package unedit Remove a package from editable mode update Update package dependencies swift package command > 1. Development Environment 1. Web Development with Swift
USAGE: swift build [options] OPTIONS: --build-path Specify build/cache directory [default: ./.build] --build-tests Build the both source and test targets --configuration, -c Build with configuration (debug|release) [default: debug] --disable-prefetching --disable-sandbox Disable using the sandbox when executing subprocesses --enable-prefetching --package-path Change working directory before any other operation --show-bin-path Print the binary output path --verbose, -v Increase verbosity of informational output -Xcc Pass flag through to all C compiler invocations -Xcxx Pass flag through to all C++ compiler invocations -Xlinker Pass flag through to all linker invocations -Xswiftc Pass flag through to all Swift compiler invocations --help Display available options > 1. Development Environment 1. Web Development with Swift swift build command
……… Removing intermediate container 2a1e07e3bb29 Successfully built 2b7cd7f22a1b Successfully tagged hello-spm: Build > 2. Hello World on Linux 1. Web Development with Swift
……… Removing intermediate container 2a1e07e3bb29 Successfully built 2b7cd7f22a1b Successfully tagged hello-spm: Build Run /Users/yuki/Desktop/HelloSPM % docker run -it -t hello-spm Hello, world! > 2. Hello World on Linux 1. Web Development with Swift
Server is not provided in Swift Standard Lib • So almost WebFrameworks has Web Server • Covering ORM / Database Driver, JWT and Template engines etc… 3. Web Frameworks > 3. Web Frameworks 1. Web Development with Swift
ELF (required runtime libraries or static link) • Working well with Ubuntu and RedHat Distributions • Working well with ECS, Kubernetes and other Container Services 4. About Deployment 1. Web Development with Swift
the cloud provider dynamically manages the allocation of machine resources, and bills based on the actual amount of resources consumed by an application, rather than billing based on pre- purchased units of capacity.” Serverless computing from wikipedia ~Serverless computing~ 2. Serverless × Swift
work flow from conventional web development • Must execute Swift from supported languages • Anyways, It’s bother to deploy APIGateway + Lambda But… 2. Serverless × Swift
APIGateway ᶄ Upload ᶃ Archive ᶅ Create Function with Uploaded Zip URL ᶆ Resource and Function Mapping Request ᶇ Deploy Request Mapping Function and Resource Serverless × Swift It’s hard….
written in Swift • Currently only supports AWS APIGateway+Lambda • Don’t need to deep knowledge for AWS • Cloud Native 1. What is Hexaville? 3. Introduction of Hexaville
of Swift program to serverless environment (Routing, code deploy etc..) • Automatically create Swift execution environment on Lambda • Normal Development/Deployment work flow • iOS Developer can write backend and client with single language. can share code. > 1. What is Hexaville? 3. Introduction of Hexaville
- deploy Deploy your application to the specified cloud provider - routes Show routes and endpoint for the API - help Prints this help information - version Prints the current version of this app hexaville command > 2. Installation 3. Introduction of Hexaville
- deploy Deploy your application to the specified cloud provider - routes Show routes and endpoint for the API - help Prints this help information - version Prints the current version of this app hexaville command > 2. Installation 3. Introduction of Hexaville
manifest file that have dependencies, app settings Sources/main.swift - entrypoint Sources/RandomNumberGenerateMiddleware.swift - An example code of Middleware > 2. Installation 3. Introduction of Hexaville
APIGateway ᶄ Upload ᶃ Archive ᶅ Create Function with S3 URL ᶆ Resource(Path) and Function Mapping ᶇ Deploy ᶆ’ mapping > 4. How is Swift executed on lambda? 3. Introduction of Hexaville
APIGateway ᶄ Upload ᶃ Archive ᶅ Create Function with S3 URL ᶆ Resource(Path) and Function Mapping ᶇ Deploy ᶆ’ mapping > 4. How is Swift executed on lambda? 3. Introduction of Hexaville Totally Automated!!
Ubuntu ᶄ Put the ELF into the Host Machine Deployment Flow of Hexaville > 4. How is Swift executed on lambda? 3. Introduction of Hexaville ᶃ Build (call hexaville deploy)
App Code Your Web App Ubuntu ᶄ Put the ELF into the Host Machine Deployment Flow of Hexaville Zip file > 4. How is Swift executed on lambda? 3. Introduction of Hexaville ᶃ Build (call hexaville deploy)
Hexaville Framework Web App Code Your Web App Ubuntu ᶄ Put the ELF into the Host Machine Deployment Flow of Hexaville Zip file > 4. How is Swift executed on lambda? 3. Introduction of Hexaville ᶃ Build (call hexaville deploy)
ᶆ Deploy Hexaville Framework Web App Code Your Web App Ubuntu ᶄ Put the ELF into the Host Machine Deployment Flow of Hexaville Zip file Introduction of Hexaville > 2. How is Swift executed on lambda?
Hello /Users/yuki/Desktop/Hello % swift build /Users/yuki/Desktop/Hello % ./.build/debug/Hello Available commands: - gen-routing-manif Generate routing manifest file - execute Execute the specified resource. ex. execute GET / - serve Start Hexaville Builtin Server - help Prints this help information - version Prints the current version of this app 3. Introduction of Hexaville
/Users/yuki/Desktop/Hello % ./.build/debug/Hello Available commands: - gen-routing-manif Generate routing manifest file - execute Execute the specified resource. ex. execute GET / - serve Start Hexaville Builtin Server - help Prints this help information - version Prints the current version of this app > 5. How to Debug? 3. Introduction of Hexaville
localhost:3000 <html><head><title>Hexaville</title></head><body>Welcome to Hexaville!</body></html> > 5. How to Debug? 3. Introduction of Hexaville /Users/yuki/Desktop/Hello % ./.build/debug/Hello serve Hexaville Builtin Server started at 0.0.0.0:3000 Serve builtin web server
{ error in print(error) // stdout will be output to Cloud Watch Logs // or // SendLog to Fluentd or something switch error { case FooError.notFound: return Response(status: .notFound) case JWTAuthenticationMiddleware.authrozationHeaderIsMissing: return Response(status: .unauthorized) default: return Response(status: .internalServerError) } } try app.run() > 5. How to Debug? 3. Introduction of Hexaville
with Hexaville Using in TODO Example • Redis (IBM-Swift, Vapor) • MySQL (noppoMan, IBM-Swift) • Postgres (IBM-Swift) • MongoDB (OpenKitten) Other Available DB Clients
is not a daemon on Serverless • —> Can’t keep connection for RDBMS • 1 HTTP Request = 1 Connection of RDBMS • —> Your RDBMS will hang up RDBMS and Serverless 4. Create Practical Web App with Hexaville > Hexaville on production
and Installable just one line command • Doesn’t need to install Swift Language and Runtime • just 3 steps: git push -> test -> hexaville deploy Continuous Integration and Hexaville >Continuous Integration and Hexaville 4. Create Practical Web App with Hexaville