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

potatotips#8 Swiftのライブラリを作成/利用しよう

tokorom
August 20, 2014

potatotips#8 Swiftのライブラリを作成/利用しよう

Objective-CじゃなくてSwiftのライブラリを利用する方法、また、自分で作る方法

tokorom

August 20, 2014
Tweet

More Decks by tokorom

Other Decks in Programming

Transcript

  1. SwiftͰΞϓϦ։ൃ #1

    SwiftͷϥΠϒϥϦΛ࡞੒/ར༻͠Α͏
    Yuta ToKoRo

    iOS App Programer
    potatotips #8

    View full-size slide

  2. ॴ༑ଠ
    @tokorom

    View full-size slide

  3. ࠓ೔͸͜ͷ͋ͨΓʹ͍ͭͯ
    •SwiftͰطଘͷObjective-CͷϥΠϒϥϦΛ࢖͏
    ৘ใ͸ͨ͘͞Μ͋Δ͕ɺSwiftͷϥΠϒϥϦʹͭ
    ͍ͯ͸͋·Γ৘ใ͕ͳ͍͚ͲͲ͏΍Δͷʁ
    •CocoaPods͸ݱঢ়࢖͑ͳ͍ͷͰͲ͏͠Α͏ʁ
    •ࣗ෼ͰϥΠϒϥϦ࡞Δͱ͖͸Ͳ͏͠Α͏ʁ

    View full-size slide

  4. SwiftͷϥΠϒϥϦΛ࢖ͬͯΈΔ
    •Quick͕Φεεϝ
    •https://github.com/Quick/Quick
    •ςετίʔυ༻ϥΠϒϥϦʢKiwiͷSwift൛ʣ
    •Objective-CͷϓϩδΣΫτͰ΋ςετ͚ͩQuickͱ͍͏
    ͷ΋ΞϦ͔΋͠Εͳ͍
    •READMEʹΠϯετʔϧͷ͔͕ͨ͠ॻ͍ͯ͋Δ
    •Nimbleͱ͍͏ผͷϥΠϒϥϦ΋࢖͍ͬͯΔͨΊͦ͏͍͏
    ߏ੒ͷϥΠϒϥϦΛ࢖͏ʢ࡞Δʣ࿅शʹ΋ͳΔ

    View full-size slide

  5. QuickͷΠϯετʔϧํ๏
    •QuickͱNimbleΛclone͢Δ
    •ࣗ෼ͷϓϩδΣΫτʹ Quick.xcodeproj ͱ
    Nimble.xcodeproj ΛAdd͢Δ
    •ςετ༻ͷTargetʹ͚ͩνΣοΫ͢Δ

    View full-size slide

  6. QuickͷΠϯετʔϧํ๏
    •ςετ༻Targetͷ Link Binary With Libraries
    ʹ Quick.framework ͱ Nimble.framework Λ
    Ճ͑Δ

    View full-size slide

  7. QuickͷΠϯετʔϧํ๏
    •͋ͱ͸SpecΛॻ͍ͯ࢖͏͚ͩʂ

    View full-size slide

  8. ϥΠϒϥϦΛ࢖͏ͱ͖ͷ·ͱΊ
    •ϥΠϒϥϦͷxcodeprojΛϓϩδΣΫτʹ௥Ճ
    •ϥΠϒϥϦͷframeworkΛ Link Binary With
    Libraries ʹ௥Ճ
    •͜ͷͱ͖ϥΠϒϥϦ͕࢖͍ͬͯΔϥΠϒϥϦ΋
    Ұॹʹ௥Ճ͢Δඞཁ͕͋Δ

    View full-size slide

  9. CocoaPods͕࢖͑ͳ͍ʁ
    •ࠓͷͱ͜ΖSwiftͷϥΠϒϥϦʹ͸࢖͑ͳ͍
    •git submoduleΛ࢖͍·͠ΐ͏
    •git submoduleͰऔಘͨ͠ϑΝΠϧͷதͰ
    QuickͱNimbleͷxcodeprojΛϓϩδΣΫτʹ
    Add͢Ε͹OK

    View full-size slide

  10. git submoduleʹ͓ͯ͘͠ϝϦοτ
    •ຊՈ͕ߋ৽͞ΕͨΒ͙͢ʹupdateͰ͖Δ
    •Xcodeͷbeta൛UpdateʹΑΓຊ͕݅ར༻Ͱ͖
    ͳ͍ͱ͖ʹࣗ෼ͷforkઌʹܨ͗ม͑ΔɺͩΕ͔
    ͕forkઌͰमਖ਼ࡁΈͳΒͦ͜ʹ੾Γସ͑Δɺͱ
    ͍ͬͨ͜ͱ͕༰қ
    •طଘͷObjective-CͷϥΠϒϥϦͷΑ͏ʹෳࡶ
    ͳઃఆ͕ඞཁͳ͍ͷͰࠓͷͱ͜ΖsubmoduleͰ
    ಛʹࠔ͍ͬͯͳ͍

    View full-size slide

  11. SwiftͷϥΠϒϥϦΛ࡞ͬͯΈΑ͏
    •ϓϩδΣΫτΛ࡞Δͱ͖͸ Cocoa Touch
    Framework Λબ୒͢Δ

    View full-size slide

  12. SwiftͷϥΠϒϥϦΛ࡞ͬͯΈΑ͏
    •ϥΠϒϥϦ໊.h ͕Ͱ͖ΔͷͰɺObjective-C
    ίʔυ΋࢖͏৔߹ʹ͸ͦ͜Ͱ import

    View full-size slide

  13. SwiftͷϥΠϒϥϦΛ࡞ͬͯΈΑ͏
    •importͨ͠ϔομʔ͸ Public ଐੑʹ͢Δ

    View full-size slide

  14. SwiftͷϥΠϒϥϦΛ࡞ͬͯΈΑ͏
    •Build Phasesͷઃఆ
    ࢖͍ͬͯΔϥΠϒϥϦΛ
    ͜͜ʹ௥Ճ
    Ϗϧυ࣌ʹґଘϥΠϒϥ
    Ϧ΋Ϗϧυ͍ͨ͠৔߹͸
    ͜͜ʹ௥Ճ

    View full-size slide

  15. SwiftͷϥΠϒϥϦΛ࡞ͬͯΈΑ͏
    •ςετ༻TargetͷBuild Phasesͷઃఆ
    ϥΠϒϥϦ͕࢖͍ͬͯΔ
    ϥΠϒϥϦ
    ςετ͢ΔϥΠϒϥϦࣗମ
    ςετ༻ϥΠϒϥϦ

    View full-size slide

  16. Enjoy Swift :)

    View full-size slide

  17. More Information
    Yuta ToKoRo!
    iOS App Programer!
    !
    @tokorom!
    http://www.tokoro.me/

    View full-size slide