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.7k
1年分のデータが見たいと言われてやったこと/yearly_data_with_note
fromkk
0
870
note iOSチームの自動化 ver.2021/automation_with_iOS_team_on_note_ver2021
fromkk
0
1.8k
Bitrise体験会説明資料/bitrise_explore
fromkk
1
1k
noteのiOSアプリで実装したアクセシビリティの全て #iosdc #a /a11y_with_iOS_App_on_note
fromkk
2
3.3k
dSYMのアップロードで SPMを活用する/use_spm_with_upload_dsyms
fromkk
1
2.6k
Bitriseのリモートアクセス機能 #bitrise_meetup/remote_access_of_bitrise
fromkk
1
510
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
GraphQLの魅力を引き出すAndroidクライアント実装
morux2
3
310
Prolog入門
qnighy
4
960
いまから追い上げる、Jetpack Compose トレーニング
nyafunta9858
0
240
Hono・Prisma・AWSでGeoなAPI開発
nokonoko1203
5
660
null or undefined
susisu
22
6.1k
unique パッケージから学ぶ interning と weak reference @ Asakusa.go#3
karamaru
1
230
『ドメイン駆動設計をはじめよう』中核の業務領域
masuda220
PRO
5
960
労務ドメインを快適に開発する方法 / How to Comfortably Develop in the Labor Domain
yuki21
1
250
1人で挑むSwiftコンパイラ 〜型システム入門編〜
s_shimotori
0
330
長期運用プロダクトの開発速度を維持し続けるためのリファクタリング実践例
wataruss
8
2.7k
The Sequel to a Dream of Ruby Parser's Grammar
ydah
1
210
A New Era of Testing
mannodermaus
2
150
Featured
See All Featured
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
190
16k
Thoughts on Productivity
jonyablonski
66
4.2k
Optimising Largest Contentful Paint
csswizardry
29
2.8k
Debugging Ruby Performance
tmm1
72
12k
Producing Creativity
orderedlist
PRO
340
39k
Designing with Data
zakiwarfel
98
5k
Visualization
eitanlees
142
15k
Making the Leap to Tech Lead
cromwellryan
128
8.8k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
363
22k
Designing for Performance
lara
604
68k
Navigating Team Friction
lara
183
13k
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.4k
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