Slide 1

Slide 1 text

Make ! with SPM Roppongi.swift #3 © fromkk 2018 1

Slide 2

Slide 2 text

Who is me? Kazuya Ueoka iOS application engineer in Timers inc. Twitter: @fromkk Github: fromkk Qiita: fromkk © fromkk 2018 2

Slide 3

Slide 3 text

લఏ • macOS High Sierra • Xcode 9.3 © fromkk 2018 3

Slide 4

Slide 4 text

ݕ౼ͨ͠πʔϧ • Imagemagick • GD Graphics Library © fromkk 2018 4

Slide 5

Slide 5 text

ࠓճ͸ GD Λར༻ © fromkk 2018 5

Slide 6

Slide 6 text

ԿނAppKit࢖Θͳ͍ͷ͔ • GDͳΒLinux͔ΒͰ΋ར༻ग़དྷΔҝ © fromkk 2018 6

Slide 7

Slide 7 text

GDͷΠϯετʔϧ brew install gd © fromkk 2018 7

Slide 8

Slide 8 text

Swift͔ΒCݴޠͷϥΠϒϥϦΛར༻͢Δ © fromkk 2018 8

Slide 9

Slide 9 text

module.modulemap Λ࡞੒ mkdir ./GD && cd $_ touch module.modulemap © fromkk 2018 9

Slide 10

Slide 10 text

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

Slide 11

Slide 11 text

ಉ͡֊૚ʹ Package.swift Λ࡞੒ import PackageDescription let package = Package( name: "GD", pkgConfig: "gdlib", providers: [ .brew(["gd"]) ] ) © fromkk 2018 11

Slide 12

Slide 12 text

GitͰλά෇͚ git init . git add . git commit -m "Initial commit" git tag 0.0.1 -m "Initial commit" © fromkk 2018 12

Slide 13

Slide 13 text

ϓϩδΣΫτΛ࡞੒ cd ../ && mkdir ./MyProject && cd $_ swift package init --type executable © fromkk 2018 13

Slide 14

Slide 14 text

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

Slide 15

Slide 15 text

Ұ౓Ϗϧυ͢Δ 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

Slide 16

Slide 16 text

XcodeprojΛ࡞੒ swift package generate-xcodeproj © fromkk 2018 16

Slide 17

Slide 17 text

ϑΥϧμߏ੒ 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

Slide 18

Slide 18 text

GDͷجૅ © fromkk 2018 18

Slide 19

Slide 19 text

ը૾৽ن࡞੒ import GD let width: Int32 = 640 let height: Int32 = 480 let image = gdImageCreateTrueColor(width, height) © fromkk 2018 19

Slide 20

Slide 20 text

ը૾อଘ import GD let handler = fopen("path/to/image.png", "wb") defer { fclose(handler) } gdImagePng(image, handler) © fromkk 2018 20

Slide 21

Slide 21 text

ը૾߹੒ 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

Slide 22

Slide 22 text

จࣈྻΛॻ͖ࠐΉ import GD let blackColor = gdImageColorAllocate(image, 0, 0, 0) defer { gdImageColorDeallocate(image, blackColor) } let text = UnsafeMutablePointer(mutating: "hogehoge") gdImageString(image, gdFontGetSmall(), x, y, text, blackColor) © fromkk 2018 22

Slide 23

Slide 23 text

࡞ͬͯΈͨπʔϧ https://github.com/fromkk/TestSummaries XCTestͷUIςετͷ݁ՌΛΠΠײ͡Ͱݟ͍ͨ(Qiita) Πϯετʔϧํ๏ brew install fromkk/TestSummaries/testsummaries © fromkk 2018 23

Slide 24

Slide 24 text

Demo © fromkk 2018 24

Slide 25

Slide 25 text

݁Ռ © fromkk 2018 25

Slide 26

Slide 26 text

·ͱΊ • XCTestͰࡱͬͨεΫγϣΛը૾ʹ·ͱΊͯνʔϜʹڞ༗ग़ དྷΔ༷ʹ͠·ͨ͠ • Homebrew͔Β୭Ͱ΋Πϯετʔϧग़དྷ·͢ • ·ͩ·ͩաڈͷࢿ࢈Λ׆༻͢ΔࣄͰศརͳπʔϧ͸࡞ΕΔ © fromkk 2018 26

Slide 27

Slide 27 text

PR 1 © fromkk 2018 27

Slide 28

Slide 28 text

© fromkk 2018 28

Slide 29

Slide 29 text

© fromkk 2018 29

Slide 30

Slide 30 text

© fromkk 2018 30

Slide 31

Slide 31 text

PR 2 © fromkk 2018 31

Slide 32

Slide 32 text

https://pre-wwdc.connpass.com/event/83346/ © fromkk 2018 32

Slide 33

Slide 33 text

͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ © fromkk 2018 33