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
900
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.7k
Bitriseのリモートアクセス機能 #bitrise_meetup/remote_access_of_bitrise
fromkk
1
530
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
GitHubで育つ コラボレーション文化 : ニフティでのインナーソース挑戦事例 - 2024-12-16 GitHub Universe 2024 Recap in ZOZO
niftycorp
PRO
0
120
数十万行のプロジェクトを Scala 2から3に完全移行した
xuwei_k
0
350
PHPで作るWebSocketサーバー ~リアクティブなアプリケーションを知るために~ / WebSocket Server in PHP - To know reactive applications
seike460
PRO
2
650
今年のアップデートで振り返るCDKセキュリティのシフトレフト/2024-cdk-security-shift-left
tomoki10
0
230
ゆるやかにgolangci-lintのルールを強くする / Kyoto.go #56
utgwkk
2
450
Monixと常駐プログラムの勘どころ / Scalaわいわい勉強会 #4
stoneream
0
290
週次リリースを実現するための グローバルアプリ開発
tera_ny
1
110
Zoneless Testing
rainerhahnekamp
0
120
今年一番支援させていただいたのは認証系サービスでした
satoshi256kbyte
1
260
各クラウドサービスにおける.NETの対応と見解
ymd65536
0
180
useSyncExternalStoreを使いまくる
ssssota
6
1.4k
わたしの星のままで一番星になる ~ 出産を機にSIerからEC事業会社に転職した話 ~
kimura_m_29
0
200
Featured
See All Featured
Java REST API Framework Comparison - PWX 2021
mraible
28
8.3k
Scaling GitHub
holman
459
140k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
44
9.3k
Put a Button on it: Removing Barriers to Going Fast.
kastner
59
3.6k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
Statistics for Hackers
jakevdp
796
220k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
59k
Intergalactic Javascript Robots from Outer Space
tanoku
270
27k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
2
290
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
Designing Experiences People Love
moore
138
23k
VelocityConf: Rendering Performance Case Studies
addyosmani
326
24k
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