Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Make 🖼 with SPM #roppongiswift/make_image_with_spm
Search
fromkk
May 23, 2018
Programming
2
1.8k
Make 🖼 with SPM #roppongiswift/make_image_with_spm
Roppongi.swift #3で発表してきた内容です。
Swift Package Managerで画像を生成する事にトライしました。
fromkk
May 23, 2018
Tweet
Share
More Decks by fromkk
See All by fromkk
note社の全員野球で品質向上活動について / note_qa_challenge #iOS_test_teatime
fromkk
3
1.8k
1年分のデータが見たいと言われてやったこと/yearly_data_with_note
fromkk
0
890
note iOSチームの自動化 ver.2021/automation_with_iOS_team_on_note_ver2021
fromkk
0
1.9k
Bitrise体験会説明資料/bitrise_explore
fromkk
1
1k
noteのiOSアプリで実装したアクセシビリティの全て #iosdc #a /a11y_with_iOS_App_on_note
fromkk
2
3.4k
dSYMのアップロードで SPMを活用する/use_spm_with_upload_dsyms
fromkk
1
2.6k
Bitriseのリモートアクセス機能 #bitrise_meetup/remote_access_of_bitrise
fromkk
1
520
note社でのMagic Pod活用事例 #af_iosdc/magicpod_with_note
fromkk
2
10k
iOSには無いmacOS独自機能をCatalystで実装する #iosdc #d/make_macos_apps_with_catalyst
fromkk
9
2k
Other Decks in Programming
See All in Programming
Ethereum_.pdf
nekomatu
0
460
ヤプリ新卒SREの オンボーディング
masaki12
0
130
受け取る人から提供する人になるということ
little_rubyist
0
230
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
100
Hotwire or React? ~アフタートーク・本編に含めなかった話~ / Hotwire or React? after talk
harunatsujita
1
120
タクシーアプリ『GO』のリアルタイムデータ分析基盤における機械学習サービスの活用
mot_techtalk
4
1.4k
EventSourcingの理想と現実
wenas
6
2.3k
WebフロントエンドにおけるGraphQL(あるいはバックエンドのAPI)との向き合い方 / #241106_plk_frontend
izumin5210
4
1.4k
subpath importsで始めるモック生活
10tera
0
300
Click-free releases & the making of a CLI app
oheyadam
2
110
ECS Service Connectのこれまでのアップデートと今後のRoadmapを見てみる
tkikuc
2
250
Why Jakarta EE Matters to Spring - and Vice Versa
ivargrimstad
0
1.1k
Featured
See All Featured
Docker and Python
trallard
40
3.1k
Documentation Writing (for coders)
carmenintech
65
4.4k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Git: the NoSQL Database
bkeepers
PRO
427
64k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
10
720
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
506
140k
GitHub's CSS Performance
jonrohan
1030
460k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
31
2.7k
A designer walks into a library…
pauljervisheath
203
24k
Being A Developer After 40
akosma
86
590k
Transcript
Make ! with SPM Roppongi.swift #3 © fromkk 2018 1
Who is me? Kazuya Ueoka iOS application engineer in Timers
inc. Twitter: @fromkk Github: fromkk Qiita: fromkk © fromkk 2018 2
લఏ • macOS High Sierra • Xcode 9.3 © fromkk
2018 3
ݕ౼ͨ͠πʔϧ • Imagemagick • GD Graphics Library © fromkk 2018
4
ࠓճ GD Λར༻ © fromkk 2018 5
ԿނAppKitΘͳ͍ͷ͔ • GDͳΒLinux͔ΒͰར༻ग़དྷΔҝ © fromkk 2018 6
GDͷΠϯετʔϧ brew install gd © fromkk 2018 7
Swift͔ΒCݴޠͷϥΠϒϥϦΛར༻͢Δ © fromkk 2018 8
module.modulemap Λ࡞ mkdir ./GD && cd $_ touch module.modulemap ©
fromkk 2018 9
module.modulemap ༰ module GD [system] { header "/usr/local/include/gd.h" header "/usr/local/include/gdfontt.h"
header "/usr/local/include/gdfonts.h" header "/usr/local/include/gdfontl.h" header "/usr/local/include/gdfontg.h" header "/usr/local/include/gdfontmb.h" link "gd" export * } © fromkk 2018 10
ಉ͡֊ʹ Package.swift Λ࡞ import PackageDescription let package = Package( name:
"GD", pkgConfig: "gdlib", providers: [ .brew(["gd"]) ] ) © fromkk 2018 11
GitͰλά͚ git init . git add . git commit -m
"Initial commit" git tag 0.0.1 -m "Initial commit" © fromkk 2018 12
ϓϩδΣΫτΛ࡞ cd ../ && mkdir ./MyProject && cd $_ swift
package init --type executable © fromkk 2018 13
Package.swift Λฤू import PackageDescription let package = Package( name: "MyProject",
dependencies: [ .package(url: "../GD", from: "0.0.1"), ], targets: [ .target( name: "MyProject", dependencies: []), ] ) © fromkk 2018 14
ҰϏϧυ͢Δ swift build ↓ Fetching /PATH/TO/GD Cloning /PATH/TO/GD Resolving /PATH/TO/GD
at 0.0.1 Compile Swift Module 'MyProject' (1 sources) Linking ./.build/x86_64-apple-macosx10.10/debug/MyProject GD ͕ϑΣον͞ΕͯͪΌΜͱϏϧυ͞Ε͍ͯΔࣄΛ֬ೝ © fromkk 2018 15
XcodeprojΛ࡞ swift package generate-xcodeproj © fromkk 2018 16
ϑΥϧμߏ tree . . ├── GD │ ├── Package.swift │
└── module.modulemap └── MyProject ├── MyProject.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ ├── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ │ └── xcuserdata │ │ └── fromkk.xcuserdatad │ │ └── UserInterfaceState.xcuserstate │ ├── xcshareddata │ │ └── xcschemes │ │ ├── MyProject-Package.xcscheme │ │ └── xcschememanagement.plist │ └── xcuserdata │ └── fromkk.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── Package.resolved ├── Package.swift ├── README.md ├── Sources │ └── MyProject │ └── main.swift └── Tests © fromkk 2018 17
GDͷجૅ © fromkk 2018 18
ը૾৽ن࡞ import GD let width: Int32 = 640 let height:
Int32 = 480 let image = gdImageCreateTrueColor(width, height) © fromkk 2018 19
ը૾อଘ import GD let handler = fopen("path/to/image.png", "wb") defer {
fclose(handler) } gdImagePng(image, handler) © fromkk 2018 20
ը૾߹ import GD let file = fopen("copy/image/path.png", "rb") defer {
fclose(file) } let copyImage = gdImageCreateFromPng(file) gdImageCopy(image, copyImage, dstX, dstY, srcX, srcY, width, height) © fromkk 2018 21
จࣈྻΛॻ͖ࠐΉ import GD let blackColor = gdImageColorAllocate(image, 0, 0, 0)
defer { gdImageColorDeallocate(image, blackColor) } let text = UnsafeMutablePointer<UInt8>(mutating: "hogehoge") gdImageString(image, gdFontGetSmall(), x, y, text, blackColor) © fromkk 2018 22
࡞ͬͯΈͨπʔϧ https://github.com/fromkk/TestSummaries XCTestͷUIςετͷ݁ՌΛΠΠײ͡Ͱݟ͍ͨ(Qiita) Πϯετʔϧํ๏ brew install fromkk/TestSummaries/testsummaries © fromkk 2018
23
Demo © fromkk 2018 24
݁Ռ © fromkk 2018 25
·ͱΊ • XCTestͰࡱͬͨεΫγϣΛը૾ʹ·ͱΊͯνʔϜʹڞ༗ग़ དྷΔ༷ʹ͠·ͨ͠ • Homebrew͔Β୭ͰΠϯετʔϧग़དྷ·͢ • ·ͩ·ͩաڈͷࢿ࢈Λ׆༻͢ΔࣄͰศརͳπʔϧ࡞ΕΔ © fromkk
2018 26
PR 1 © fromkk 2018 27
© fromkk 2018 28
© fromkk 2018 29
© fromkk 2018 30
PR 2 © fromkk 2018 31
https://pre-wwdc.connpass.com/event/83346/ © fromkk 2018 32
͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ © fromkk 2018 33