Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Nayami Enumerations

Nayami Enumerations

第一部:悩みの列挙
- 個人開発の悩みを列挙します。

第二部:ライブラリを作った話
1. ライブラリの作り方( Carthage 対応)
2. Instagram へ写真をシェアするだけの
ライブラリ紹介
3. ドキュメント自動生成ツールの紹介

Satoshi Hachiya

January 23, 2016
Tweet

More Decks by Satoshi Hachiya

Other Decks in Programming

Transcript

  1. private enum Nayami: ErrorType { case GitHub case English case

    Instagram case Framework case Git case TravisCI(CocoaPods) case Documentation ... 7
  2. • enum • Realm • Carthage • CocoaPods • .podspec

    ΠφϜ / ΠʔφϜ Ϩ ϧ Ϝ Χϧλΰ / Χοηʔδ ί ί Ξ ϙ ο ζ ϙ ο υ εϖ ο Ϋ 13 • TravisCI • SwiftKitten • jazzy • SwiftLint • reflog τϥϏεγʔΞΠ εΠ ϑ τ Ω ο τ Ρϯ δ ϟ δ ʔ ε Π ϑ τ Ϧ ϯ τ Ϧ ϑ ϩ ά
  3. ରࡦ • 2015೥12݄14೔ɺGitHub Patchwork KOBE ʹ ࢀՃ͠·ͨ͠ɻ
 http://patchwork-kobe.peatix.com • ͦͷ࣌఺Ͱۭ͖͕͋ͬͨͷͰཌ15೔ͷ

    Osaka×GitHub MEETUP!! ʹࢀՃ͠·ͨ͠ɻ
 https://www.facebook.com/events/ 1691655947787603/ 17
  4.  418d1b4 HEAD@{0}: checkout: moving from develop to cocoa_kansai 418d1b4

    HEAD@{1}: commit: Update SharingFlowResult.swift b259946 HEAD@{2}: commit: Fix Documentation/SharingFlowClassReference.md 5dfa503 HEAD@{3}: commit: Fix #21 and add test cases 93190a4 HEAD@{4}: reset: moving to 93190a4873a574e0973529517178dfce874a78a3 8bf764a HEAD@{5}: commit: Fix #21 and add test cases 93190a4 HEAD@{6}: ... dca5cad HEAD@{7}: ... 4239d94 HEAD@{8}: ... dca5cad HEAD@{9}: ... e6b1f43 HEAD@{10}: ... dca5cad HEAD@{11}: ... 5173a14 HEAD@{12}: ... dca5cad HEAD@{13}: ... b4ee1a6 HEAD@{14}: ... dca5cad HEAD@{15}: ... b8c2a43 HEAD@{16}: ... dca5cad HEAD@{17}: ... 2cdd5f3 HEAD@{18}: ... 1e0b0c4 HEAD@{19}: ... 97556b6 HEAD@{20}: ... 1e0b0c4 HEAD@{21}: ... 8d2233f HEAD@{22}: ... 818112a HEAD@{23}: ... 1e0b0c4 HEAD@{24}: ... 492c6f8 HEAD@{25}: ... 1e0b0c4 HEAD@{26}: ... f9136cf HEAD@{27}: ...
  5. Ͳ͏͍͏͜ͱ͔ • GitHub ΁ Push ͨ͠ͱ͖ʹ Travis CI ্Ͱ build

    ʹ
 ࣦഊ͠·͢ɻ ‣ཧ༝
 ·ͩ GitHub ্ͰόʔδϣϯΞοϓʢλά෇͚ʣͯ͠
 ͍ͳ͍ͨΊɺઌʹ৽͍͠όʔδϣϯͷ .podspec Λ 
 push ͢Δͱόʔδϣϯ͕Ұக͠·ͤΜɻ • ࣌ؒ੾ΕͰ͍͍౴͑Λ༻ҙ͍ͯ͠·ͤΜɻ
 ʢ࠶౓࣮ߦ͢Δ͚ͩͰ build ͸੒ޭ͠·͢ʣ 35
  6. Pod::Spec.new do |s| s.name = "EggsBenedict" s.version = "0.9.9" s.summary

    = "EggsBenedict is a library for sharing picture on Instagram written in Swift." s.description = <<-DESC This library is following Instagram's sharing flow. > __Instagram's documentation__ > - [Document Interaction](https://www.instagram.com/developer/mobile-sharing/iphone-hooks/#document-interaction) DESC s.homepage = "https://github.com/JPMartha/EggsBenedict" s.license = { :type => "MIT", :file => "LICENSE" } s.author = "JPMartha" s.social_media_url = "https://twitter.com/JPMartha_jp" s.platform = :ios, "8.0" s.source = { :git => "https://github.com/JPMartha/EggsBenedict.git", :branch => 'develop', :tag => s.version } s.source_files = "EggsBenedict/**/*.swift" s.requires_arc = true end 36
  7.  /** - parameters: - NoInstagramApp: Not found Instagram app.

    - UTIIsEmpty: UTI is empty. - CannotManipulateImage: Cannot manipulate image. - CannotSaveImage: Cannot save image. - ImagePathIsEmpty: ImagePath is empty. */ ``ͰғΉͱ දࣔ͞Εͳ͍
  8.  /** - `NoInstagramApp` Not found Instagram app. - `UTIIsEmpty`

    UTI is empty. - `CannotManipulateImage` Cannot manipulate image. - `CannotSaveImage` Cannot save image. - `ImagePathIsEmpty` ImagePath is empty. */
  9.  /** __`NoInstagramApp`__: Not found Instagram app. __`UTIIsEmpty`__: UTI is

    empty. __`CannotManipulateImage`__: Cannot manipulate image. __`CannotSaveImage`__: Cannot save image. __`ImagePathIsEmpty`__: ImagePath is empty. */
  10.  /** _`NoInstagramApp`_ Not found Instagram app. _`UTIIsEmpty`_ UTI is

    empty. _`CannotManipulateImage`_ Cannot manipulate image. _`CannotSaveImage`_ Cannot save image. _`ImagePathIsEmpty`_ ImagePath is empty. */
  11.  /** __`NoInstagramApp`__ Not found Instagram app. __`UTIIsEmpty`__ UTI is

    empty. __`CannotManipulateImage`__ Cannot manipulate image. __`CannotSaveImage`__ Cannot save image. __`ImagePathIsEmpty`__ ImagePath is empty. */
  12.  /** ___`NoInstagramApp`___ Not found Instagram app. ___`UTIIsEmpty`___ UTI is

    empty. ___`CannotManipulateImage`___ Cannot manipulate image. ___`CannotSaveImage`___ Cannot save image. ___`ImagePathIsEmpty`___ ImagePath is empty. */
  13. ϥΠϒϥϦଆͰ΍Δ͜ͱ ᶃ Framework Λ࡞੒ ᶄ Carthage.pkg ΛΠϯετʔϧʢ※ࠓճলུʣ ᶅ Cartfile Λ࡞੒

    ᶆ carthage update Λ࣮ߦ ᶇ carthage build Λ࣮ߦ ᶈ GitHub Ͱ release 54
  14. ᶃ Framework Λ࡞੒ ֎෦͔ΒࢀরͰ͖ΔΑ͏ public ʹ͠·͢ɻ public final class Connpass

    {
 
 public static func sendSearchEventRequest() {
 
 // ͝ʹΐ͝ʹΐ
 
 }
 
 } 56
  15. ᶆ carthage update Λ࣮ߦ $ carthage update
 --use-submodules --platform iOS

    ⚠ Φϓγϣϯ͕ٯͩͱࣦഊ͠·ͨ͠ɻ • Φϓγϣϯ —-use-submodules ґଘ͢Δ Framework Λ Git ͷαϒϞδϡʔϧͱͯ͠௥Ճ͠·͢ɻ —-platform iOS ࠓճ iOS ͷΈΛର৅ͱͨ͠ͷͰࢦఆ͠·͢ɻ 60
  16. ᶆ carthage update Λ࣮ߦ Carthage/Build ͱ Carthage/Checkouts ϑΥϧμ ಺ʹͦΕͧΕͷ Framework

    ͷϑΝΠϧ͕
 ੜ੒͞Ε·ͨ͠ɻ ‣Himotoki ‣APIKit ‣ResultʢAPIKit ͕ґଘ͍ͯ͠·͢ʣ 61
  17. ᶇ carthage build Λ࣮ߦ $ carthage build
 —no-skip-current --platform iOS

    ⚠ Φϓγϣϯ͕ٯͩͱࣦഊ͠·ͨ͠ɻ ‣Cathage/Build/iOS/ ConnpassAPIClient.framework ͕
 ੜ੒͞Ε·ͨ͠ɻ 62
  18. .gitmodules Λੜ੒ (Carthage) [submodule "Carthage/Checkouts/Himotoki"]
 path = Carthage/Checkouts/Himotoki
 url =

    https://github.com/ikesyo/Himotoki.git [submodule "Carthage/Checkouts/Result"]
 path = Carthage/Checkouts/Result
 url = https://github.com/antitypical/Result.git [submodule "Carthage/Checkouts/APIKit"]
 path = Carthage/Checkouts/APIKit
 url = https://github.com/ishkawa/APIKit.git ‣ࣗ෼Ͱઌʹ࡞͍ͬͯͨ৔߹͸௥ه͞Ε·ͨ͠ɻ 63
  19. ᶄ carthage update Λ࣮ߦ $ carthage update --platform iOS ‣

    Carthage/Build/ iOS, MacOS, tvOS, watchOS ‣ Carthage/Checkouts/ Himotoki, ConnpassAPIClientʢࣗ࡞ʣ 70
  20. APIKit ͸ϏϧυࡁΈόΠφϦ͕ μ΢ϯϩʔυ͞Ε·͢ *** Fetching ConnpassAPIClient *** Fetching Himotoki ***

    Fetching APIKit *** Fetching Result *** Checking out ConnpassAPIClient at "v0.0.8-alpha" *** Checking out Himotoki at "1.3.2" *** Downloading APIKit.framework binary at "1.1.2: Fix Content-Type" *** Downloading Result.framework binary at "1.0.1: A New Beginning" *** xcodebuild output can be found in ....log *** Building scheme "Himotoki-iOS" in Himotoki.xcodeproj *** Building scheme "ConnpassAPIClient" in ConnpassAPIClient.xcodeproj 71
  21. Framework Λ import ࣮ͯ͠ߦ import UIKit import ConnpassAPIClient // ࣗ࡞ϥΠϒϥϦ

    class ViewController: UIViewController { @IBAction func buttonTapped(sender: UIButton) {
 // Connpass͔Β”ؔ੢ϞόΠϧΞϓϦݚڀձ”Λݕࡧ Connpass.sendSearchEventRequest() 
 } } 76
  22. ੒ޭ
 ʢJSON Λσίʔυͯ͠ϩάग़ྗ͢Δ͚ͩͷΫιϥΠϒϥϦʣ results_returned: 9 results_available: 9 results_start: 1 event_id:

    23958 title: ؔ੢ϞόΠϧΞϓϦݚڀձ #9 description: <p>iOS/AndroidΞϓϦ։ൃऀ޲͚ͷษڧձͰ͢ɻ</p> <h1>ձ৔</h1> <p>͸ͯͳژ౎ΦϑΟε8F ηϛφʔϧʔϜ</p> <p>19࣌10෼ΑΓड෇Λ։࢝͠·͢ɻ</p> <h2>ೖΓํ</h2> <p>19࣌ʹͳΔͱϏϧͷਖ਼໘ೖΓޱͷγϟολʔ͕ԼΓ·͢ɻ޲͔ͬͯࠨखͷ௨Γʹ͋Δ௨༻ޱ͔Β͓ೖΓ͍ͩ͘͞ɻ௨༻ޱ͕ด·ͬ ͍ͯΔ৔߹ʹ͸Πϯλʔϗϯ͔Βʮ801ʯΛݺͼ͍ͩͯͩ͘͠͞ɻ</p> <h1>։࠵֓ཁ</h1> <p>࠷ߴͷϞόΠϧΞϓϦΛ࡞Γ͍ͨσϕϩούʔ͕ɺ͓ޓ͍ʹ࠷৽ͷ஌ݟΛ൸࿐ͯ͠ަྲྀ͢ΔݚڀձͰ͢ɻ</p> <p>ͦΕͧΕͷൃද͸࣋ͪ࣌ؒ5෼ͷϥΠτχϯάτʔΫʢLTʣܗࣜͱ͠·͢ɻݪଇͱͯ͠5෼Ҏ಺ʹɺҴ࠺ͷΑ͏ͳ଎͞ͱ੎͍Ͱ͓࿩ ͍͖ͨͩ͠·͢ɻ</p> <h1>࠙਌ձ</h1> <p>ൃදऴྃޙʹ࠙਌ձΛاը͍ͯ͠·͢ɻฃͬͯ͝ࢀՃ͍ͩ͘͞ɻ</p> <p>Ϗʔϧ΍ܰ৯Λ༻ҙ͍ͯ͠·͢ɻ</p> <h1>λΠϜςʔϒϧ</h1> <p>TBD</p> event_url: http://kanmoba.connpass.com/event/23958/ 
  23. ࠷ޙʹࣗ࡞ϥΠϒϥϦͰ͓ࢼ͠ $ carthage archive ConnpassAPIClient ‣࣮ߦ݁Ռ *** Found Carthage/Build/iOS/ConnpassAPIClient.framework ***

    Found Carthage/Build/iOS/ConnpassAPIClient.framework.dSYM *** Found Carthage/Build/iOS/2209388D-3339-30F6-B80B-A779B6C91550.bcsymbolmap *** Found Carthage/Build/iOS/3841BD75-0DB2-3250-8395-786A569C7368.bcsymbolmap *** Created ConnpassAPIClient.framework.zip ‣ϦϙδτϦͷ௚ԼʹzipϑΝΠϧ͕ੜ੒͞Ε·ͨ͠ɻ 78
  24. 

  25. ίʔυղੳ • ͸͡Ί͸ࣗྗͰ͠·͕ͨ͠ෳࡶͰͨ͠ɻ • SwiftKitten Λར༻͢Δ͜ͱʹ͠·ͨ͠ɻ
 ʢ jazzy ΍ SwiftLint

    ΋ར༻͍ͯ͠·͢ʣ https://github.com/jpsim/SourceKitten https://github.com/realm/jazzy https://github.com/realm/SwiftLint 88
  26. [{ "\/Users\/sathachie\/Pancake\/DemoApp\/DemoApp\/ViewController.swift" : { "key.substructure" : [ { "key.kind" :

    "source.lang.swift.decl.class", "key.offset" : 174, "key.parsed_declaration" : "class ViewController: NSViewController", "key.namelength" : 14, "key.bodyoffset" : 208, "key.bodylength" : 385, "key.length" : 14, "key.name" : "ViewController", "key.typename" : "ViewController.Type", "key.parsed_scope.end" : 34, "key.usr" : "s:C7DemoApp14ViewController", "key.nameoffset" : 174, "key.inheritedtypes" : [ { "key.name" : "NSViewController" } ], "key.annotated_decl" : "<Declaration>class ViewController : <Type usr=\"c:objc(cs)NSViewController\">NSViewController<\/Type><\/ Declaration>", "key.accessibility" : "source.lang.swift.accessibility.internal", "key.substructure" : [ { "key.kind" : "source.lang.swift.decl.function.method.instance", 89
  27. Ͳ͏͍͏Χλνʹ͢Δ͔ • Mac App • Command Line Tool ྫɿCarthage, CocoaPods,

    SwiftLint • Xcode Plugin ྫɿLin
 https://github.com/questbeat/Lin 91
  28. ࢀߟ • Carthageʹ͍ͭͯ஌Γ͍ͨnݸͷ͜ͱ
 http://www.slideshare.net/syoikeda/carthagen • iOSͰͷFrameworkಋೖͷ͓͞Β͍
 http://www.slideshare.net/syoikeda/iosframework • SwiftͰϥΠϒϥϦΛެ։͢Δ
 http://qiita.com/morizotter/items/2e45f8f94c1010ebd69f

    • SwiftΛ࢖ͬͯϞμϯͳWeb APIΫϥΠΞϯτΛര଎Ͱ։ൃ͢Δ
 http://qiita.com/giginet/items/1e64f584f948661cffd1 • γϯϓϧͳґଘؔ܎؅ཧγεςϜ Carthage
 https://realm.io/jp/news/swift-dependency-management-with-carthage/ 95
  29. ࢀߟ • jazzy
 https://github.com/realm/jazzy • SwiftLint
 https://github.com/realm/SwiftLint • SourceKitten
 https://github.com/jpsim/SourceKitten

    • Swift SourceKitΛ࢖ͬͯSwiftιʔείʔυΛϋΠϥΠτ͢Δ
 http://qiita.com/gfx/items/7f47e98762ecf6f53af5 • SourceKittenʹ͍ͭͯ
 http://www.slideshare.net/ssusera7b1a1/source-kitten 96