$30 off During Our Annual Pro Sale. View Details »
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Swift Everywhere/2019-01-23-llt6
Search
Satoshi SAKAO
January 23, 2019
Programming
0
69
Swift Everywhere/2019-01-23-llt6
社内のLTイベント「えるLT Vol.6」で発表した資料です
Satoshi SAKAO
January 23, 2019
Tweet
Share
More Decks by Satoshi SAKAO
See All by Satoshi SAKAO
Testcontainers/2024-11-20-llt32
ottijp
0
70
Pkl/2024-04-17-llt31
ottijp
0
97
JavaScriptのデバッグ/2023-09-04-llt30
ottijp
0
170
CDK for TerraformでAzureリソースをデプロイする/2023-05-15-llt29
ottijp
1
300
TWELITEへの誘い/2022-12-27-llt28
ottijp
0
170
ビルドツールBazelを触ってみた/2022-09-28-llt27
ottijp
0
180
HashiCorp Vaultを使ったシークレットのセキュアな一元管理 〜Ansibleを添えて〜/2022-07-12-llt26
ottijp
0
160
AWSインフラのデプロイをCDKでカイゼンする/2022-03-23-llt25
ottijp
0
100
Amazon Timestreamでデータ補間/2021-12-27-llt24
ottijp
0
110
Other Decks in Programming
See All in Programming
SwiftUIで本格音ゲー実装してみた
hypebeans
0
320
AIコーディングエージェント(Manus)
kondai24
0
170
俺流レスポンシブコーディング 2025
tak_dcxi
14
8.7k
AIコーディングエージェント(Gemini)
kondai24
0
210
從冷知識到漏洞,你不懂的 Web,駭客懂 - Huli @ WebConf Taiwan 2025
aszx87410
2
2.5k
S3 VectorsとStrands Agentsを利用したAgentic RAGシステムの構築
tosuri13
6
310
AWS CDKの推しポイントN選
akihisaikeda
1
240
Github Copilotのチャット履歴ビューワーを作りました~WPF、dotnet10もあるよ~ #clrh111
katsuyuzu
0
110
まだ間に合う!Claude Code元年をふりかえる
nogu66
5
820
テストやOSS開発に役立つSetup PHP Action
matsuo_atsushi
0
150
モデル駆動設計をやってみようワークショップ開催報告(Modeling Forum2025) / model driven design workshop report
haru860
0
270
React Native New Architecture 移行実践報告
taminif
1
150
Featured
See All Featured
Art, The Web, and Tiny UX
lynnandtonic
303
21k
For a Future-Friendly Web
brad_frost
180
10k
A designer walks into a library…
pauljervisheath
210
24k
Practical Orchestrator
shlominoach
190
11k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.2k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
37
2.6k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
122
21k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
34k
Faster Mobile Websites
deanohume
310
31k
How To Stay Up To Date on Web Technology
chriscoyier
791
250k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Transcript
Swift Everywhere Satoshi SAKAO えるLT Vol.6 2019/01/23 (Wed) E1
話すひと E2 インフォコム株式会社 オープンイノベーションセンター " アプリケーションエンジニア JS (ES6) / Node.js
/ GCP / IoT / iOS (Swift) エースコンバット7 Satoshi SAKAO @ottijp
E3 I ❤ Swift.
E4 Swiftは何を作るための言語?
Not only E5 macOSアプリ iOSアプリ
But also E6 サーバサイド 組み込み
E7 簡単なIoTシステムを全部Swiftで作った
構成 E8
できあがったもの E9
E10 サーバサイド
Vapor • Webフレームワーク • 他の一般的なWebフレームワークと同じような感じ • ORM・認証・暗号化・WebSocket・テンプレートエンジンなどの パッケージが一通り揃っている • Herokuへのデプロイを標準でサポート(buildpackの提供)
• Xcodeでの開発をサポート(Xcodeプロジェクトの作成) • モダンで型安全で速い!! E11
Vapor E12 https://medium.com/@codevapor/vapor-3-0-0-released-8356fa619a5d
E13 組み込み
ラズパイでSwift • ずいぶん前に買って放置していたラズパイを使った • uraimo/buildSwiftOnARM のビルド済みSwiftを利用 • ライブラリ • HTTPクライアントは
shiroyagicorp/swift-seeurl を利用 • uramio/SwiftyGPIO でGPIOピンを制御 E14
SPM: Swift Package Manager E15 1 // swift-tools-version:4.0 2 //
The swift-tools-version declares the minimum version of Swift required to build this package. 3 4 import PackageDescription 5 6 let package = Package( 7 name: "SwiftyPi", 8 dependencies: [ 9 .package(url: "https://github.com/uraimo/SwiftyGPIO.git", from: "1.0.0"), 10 .package(url: "https://github.com/shiroyagicorp/swift-seeurl.git", from: "1.9.0") 11 ], 12 targets: [ 13 .target( 14 name: "SwiftyPi", 15 dependencies: ["SwiftyGPIO", "SeeURL"]), 16 ] 17 )
E16 iOSアプリ(省略)
構成 E17
まとめ • SwiftはmacOS/iOSアプリを作るためだけのものじゃない • サーバサイドも組み込みもOK! • AWS Lambdaのファンクションも作れるし, 公式Dockerイメージもある •
macOS/iOSアプリ開発のスキルセットを他に応用できるかも • 型安全でパフォーマンスの良いSwiftが多分野で広まってほしい E18
E19 You also will ❤ Swift.
$ exit E20
E21 Appendix
環境 • WebAPIサーバ • Swift 4.2 / Vapor 3.0 /
Heroku (Heroku-16 stack) • iOSアプリ • Swift 4.2 / iOS 12.1 • エンドデバイス • Swift 4.1.3 / Raspbery Pi 3 Model B / Rasbian 2018-11-13 (Debian 9.6) • 開発環境 • macOS 10.14.2 (Mojave) / Xcode 10.1 E22
コードとブログ • 作ったコード • https://github.com/ottijp/all-swift-iot-server • https://github.com/ottijp/all-swift-iot-enddevice • https://github.com/ottijp/all-swift-iot-client •
書いたブログ • https://qiita.com/ottijp/items/51a2666279f767aaa7a2 E23
詰まったところ(サーバサイド) • Futureの概念の理解 • SwiftNIOの機能 • 非同期のためのもので,JSのPromiseみたいなもの • テンプレートコードを読むだけでは理解しづらかった •
ちゃんとドキュメントを読んだほうが良い • https://docs.vapor.codes/3.0/async/overview/ • PostgreSQLへの変更 • apiテンプレートのデフォルトはSQLiteのメモリ保存 • Heroku Postgresへの接続はSSL設定をDB設定に入れる必要がある E24
詰まったところ(ラズパイ) • buildSwiftOnARMのREADMEの通りにやってもビルドできない • /usr/bin/clang がない • apt-get install で作られない
• 手動でシンボリックリンクを作った • 実行可能ファイルが生成されたように見えてされてない • swiftのソースビルドに必要なパッケージを全部入れてみた • 一応動作するようになった • たまにエラーが出る • error: unable to attach DB: error: accessing build database • 原因不明 E25