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

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

0d04162c7a3c2907c059a06dbcd23cf4?s=47 tokorom
August 20, 2014

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

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

0d04162c7a3c2907c059a06dbcd23cf4?s=128

tokorom

August 20, 2014
Tweet

Transcript

  1. SwiftͰΞϓϦ։ൃ #1 SwiftͷϥΠϒϥϦΛ࡞੒/ར༻͠Α͏ Yuta ToKoRo iOS App Programer potatotips #8

  2. ॴ༑ଠ @tokorom

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

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

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

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

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

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

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

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

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

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

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

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

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

  16. Enjoy Swift :)

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