Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Swift Everywhere/2019-01-23-llt6
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Satoshi SAKAO
January 23, 2019
Programming
89
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Swift Everywhere/2019-01-23-llt6
社内のLTイベント「えるLT Vol.6」で発表した資料です
Satoshi SAKAO
January 23, 2019
Transcript
25 slides
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
More Decks by Satoshi SAKAO
See All by Satoshi SAKAO
Testcontainers/2024-11-20-llt32
ottijp
0
120
Pkl/2024-04-17-llt31
ottijp
0
140
JavaScriptのデバッグ/2023-09-04-llt30
ottijp
0
210
CDK for TerraformでAzureリソースをデプロイする/2023-05-15-llt29
ottijp
1
370
TWELITEへの誘い/2022-12-27-llt28
ottijp
0
200
ビルドツールBazelを触ってみた/2022-09-28-llt27
ottijp
0
240
HashiCorp Vaultを使ったシークレットのセキュアな一元管理 〜Ansibleを添えて〜/2022-07-12-llt26
ottijp
0
200
AWSインフラのデプロイをCDKでカイゼンする/2022-03-23-llt25
ottijp
0
130
Amazon Timestreamでデータ補間/2021-12-27-llt24
ottijp
0
130
Other Decks in Programming
See All in Programming
[DroidKnights 2026] Workflow AX: From Auto-Documented Policies to E2E Testing
raeminkang
0
560
作れる、でも消せるか?──安全に「枯らして消す」機能削除術 / Drain, Then Delete
chobishiba
3
1.5k
Python Lambdaにおけるテストしやすい設計とAI支援の活用 / Designing Testable Python Lambda Functions with AI
kitano_yuichi
1
320
Distance field of Julia set
kinakomoti321
0
320
社内AIエージェント「Askワンバン」における コストチューニングの取り組み
t0yohei
0
170
AIが実装を担う時代の「技術設計」と「チームマネジメント」
kamina_zzz
2
260
AI-Powered Domain-Driven Design
ziobrando
0
430
AI時代のTerminal環境を UNIX哲学で設計・運用する
yasunori0418
1
350
SODA - FACT BOOK(EN)
sodainc
1
230
Engineering Biometric UX Across Android Versions | DroidKnights 2026
ryunen344
1
190
AIがコードを書いてくれる時代、我々は何を確かめるのか
yosuke_furukawa
PRO
13
5.9k
PyConTW 2026 - AI Coding 不只是工具升級, 區域醫院醫療資訊系統協作開發與資訊團隊轉型實踐
cclai999
0
250
Featured
See All Featured
For a Future-Friendly Web
brad_frost
184
11k
Done Done
chrislema
187
17k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6.2k
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
YesSQL, Process and Tooling at Scale
rocio
174
15k
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
1
600
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
680
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
350
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.9k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
BBQ
matthewcrist
90
10k