Top Banner
Server-Side Swi* 2016.05.22@如法会#1 Daijiro Abe
16

Server-side Swift

Apr 16, 2017

Download

Engineering

Daijiro Abe
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Server-side Swift

Server-Side Swi*

2016.05.22@如法会#1 Daijiro Abe

Page 2: Server-side Swift

Swi*

2016.05.22@如法会#1 Daijiro Abe

• 普段仕事ではiOS開発に使っています • Server-Sideは趣味

• まだまだ発展途上 • 仕事で使うにはリスキー

• 将来的にはかなり期待

Page 3: Server-side Swift

swi*env

2016.05.22@如法会#1 Daijiro Abe

• https://github.com/kylef/swi*env • 複数のバージョンのSwi*を簡単に切り替えられる

• プロジェクト単位での切り替えにも対応

Page 4: Server-side Swift

CLion

2016.05.22@如法会#1 Daijiro Abe

https://www.jetbrains.com/clion/

Page 5: Server-side Swift

CLion

2016.05.22@如法会#1 Daijiro Abe

• IntelliJやAppCodeなどのJetBrains社の製品 • C/C++の開発環境だがSwi*にも対応

• コード補完 • デバッギング

Page 6: Server-side Swift

Swi* Package Manager

2016.05.22@如法会#1 Daijiro Abe

• 標準のパッケージ管理システム • Package.swi*に記述

• swi* build --init で雛形生成 • swi* build --fetch で依存ライブラリを取得

Page 7: Server-side Swift

IBM Swi* Package Catalog

2016.05.22@如法会#1 Daijiro Abe

https://swi*pkgs.ng.bluemix.net/

Page 8: Server-side Swift

Swi* Modules

2016.05.22@如法会#1 Daijiro Abe

https://swi*modules.com/

Page 9: Server-side Swift

Problems

2016.05.22@如法会#1 Daijiro Abe

• Foundationが未完成 • NSURLSession, NSPredicate などがまだ使えない!

https://github.com/apple/swi*-corelibs-foundation/blob/master/Docs/Status.md

• PureSwi*/Swi*Foundation• print()がバッファリングされる

• gulpでビルド&実行しているとログが出ない... • fflush(stdout)

• String(format: , arguments:) が使えない... • 4/12のバージョンで実装されたようです!

Page 10: Server-side Swift

HotReload

2016.05.22@如法会#1 Daijiro Abe

• ソースコードを監視し変更があればビルド&リスタート • ファイル監視

• gulp-watch • gulp.watchだとファイルの追加に対応できない

• ビルドスクリプトの実行 • child_process.execFile()

• リスタート • gulp-process.start()で実行 • gulp-procees.restart()でリスタート

Page 11: Server-side Swift

Docker

2016.05.22@如法会#1 Daijiro Abe

FROM ubuntu:wily

RUN apt-get update RUN apt-get install -qy git lsb-release curl libpython-dev libxml2-dev clang libicu-dev build-essential RUN git clone https://github.com/kylef/swiftenv.git /usr/local/swiftenv ENV SWIFTENV_ROOT /usr/local/swiftenv ENV PATH $SWIFTENV_ROOT/bin:$SWIFTENV_ROOT/shims:$PATH

RUN swiftenv install DEVELOPMENT-SNAPSHOT-2016-04-12-a

• swi*envでSwi*を入れる最小構成

Page 12: Server-side Swift

Docker

2016.05.22@如法会#1 Daijiro Abe

: (続き) # npm, gulp関係を入れる RUN apt-get install -qy nodejs npm RUN rm -rf /var/lib/apt/lists/* \ && ln -s `which nodejs` /usr/local/bin/node RUN npm install -g gulp RUN mkdir /work \ && cd /work \ && npm install gulp gulp-process gulp-watch

• gulp関係を追加

Page 13: Server-side Swift

Docker

2016.05.22@如法会#1 Daijiro Abe

: (続き) # スクリプトのコピー COPY gulpfile.js /work/gulpfile.js COPY build.sh /work/build.sh COPY dev.sh /dev.sh

RUN chmod +x /work/build.sh \ && chmod +x /dev.sh

WORKDIR /src

CMD ["/dev.sh"]

• スクリプトのコピー

Page 14: Server-side Swift

Docker

2016.05.22@如法会#1 Daijiro Abe

• gulpfile.js 1 var project = process.env.PROJECT_NAME; 2 var working_dir = process.env.WORKING_DIR; 3 4 var gulp = require('gulp'); 5 var gulpProcess = require('gulp-process'); 6 var watch = require('gulp-watch'); 7 var fs = require('fs'); 8 var exec = require('child_process').execFile; 9 10 gulp.task('copy',function(){ 11 return gulp.src(['Package.swift','Sources/*.swift','Sources/**/*.swift','Tests/*.swift','Tests/**/*.swift'], {cwd: working_dir, base: working_dir}) 12 .pipe(gulp.dest('./')); 13 }); 14 15 gulp.task('build', ['copy'], function(cb) { 16 exec('./build.sh', function(err,stdout,stderr) { 17 console.log(stdout); 18 gulpProcess.restart('swiftapp'); 19 cb(err); 20 }); 21 }); 22 23 gulp.task('watch', function(){ 24 gulpProcess.start('swiftapp','.build/debug/'+project); 25 26 watch(['Package.swift','Sources/*.swift','Sources/**/*.swift','Tests/*.swift','Tests/**/*.swift'],{ cwd: working_dir },function(event){ 27 gulp.start(["copy","build"]); 28 }); 29 });

Page 15: Server-side Swift

Demo

Page 16: Server-side Swift

Docker

2016.05.22@如法会#1 Daijiro Abe

• 紹介したファイルのリポジトリhttps://github.com/d-abe/dockers/tree/master/swi*

• 細かい質問などあれば... • Facebook • メール

https://www.facebook.com/dai.abe

[email protected]