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

iOSDC 2016 talk

iOSDC 2016 talk

iOS アプリ開発の補助ツールのベストプラクティス
https://iosdc.jp/2016/c/node/40

USAMI Kosuke

August 19, 2016
Tweet

More Decks by USAMI Kosuke

Other Decks in Programming

Transcript

  1. ϓϥΫςΟεΛߟ͑Δ » ͨͩิॿπʔϧΛಋೖ͢ΔͷͰͳ͘ɺߟ͑Α͏ » ͦ΋ͦ΋ͳͥπʔϧΛ࢖͏ͷ͔ʁ » ಋೖ͢ΔϝϦοτΛߟ͑Δ » Ͳ͏͍͏࢖͍ํ͕ྑ͍ͷ͔ʁ »

    ϝϦοτΛͭͿ͞ͳ͍ϓϥΫςΟεΛߟ͑Δ iOS ΞϓϦ։ൃͷิॿπʔϧͷϕετϓϥΫςΟε (@usamik26) - iOSDC 2016 5
  2. ϥΠϒϥϦ؅ཧπʔϧ » CocoaPods » Carthage » Swift Package Manager iOS

    ΞϓϦ։ൃͷิॿπʔϧͷϕετϓϥΫςΟε (@usamik26) - iOSDC 2016 7
  3. ԿΛ͢Δπʔϧʁ » ֎෦ϥΠϒϥϦΛΞϓϦʹ؆୯ʹऔΓࠐΉ # CocoaPods ͷઃఆྫ target 'MyApp' do pod

    'RxSwift', '~> 2.6.0' pod 'RxCocoa', '~> 2.6.0' end iOS ΞϓϦ։ൃͷิॿπʔϧͷϕετϓϥΫςΟε (@usamik26) - iOSDC 2016 8
  4. Bad Practice ϥΠϒϥϦͷιʔεΛ௚઀ฤू͢Δ » πʔϧΛ࢖͏ϝϦοτʢʹϥΠϒϥϦͷ௥Ճɾߋ৽ ָ͕ʹͳΔʣ͕ࣦΘΕΔ » ʮpod install ͠ͳ͍Ͱ͍ͩ͘͞ʯͱ͍͏஫ҙॻ

    ͖͕͋Δͱɾɾɾ » ΞϓϦͷϦϙδτϦʹϥΠϒϥϦͷฤू͕ೖΔ » ͲͷόʔδϣϯͷͲ͜Λฤू͔ͨ͠ෆ໌֬ iOS ΞϓϦ։ൃͷิॿπʔϧͷϕετϓϥΫςΟε (@usamik26) - iOSDC 2016 13
  5. Good Practice ϥΠϒϥϦΛ clone ͯ͠ฤू͢Δ » πʔϧΛ࢖͏ϝϦοτ͸ͦͷ·· » ΞϓϦͱผϦϙδτϦʹϥΠϒϥϦͷฤू͕ೖΔ »

    ͲͷόʔδϣϯͷͲ͜ʹΛฤू͔ͨ͠໌֬ʹͳΔ iOS ΞϓϦ։ൃͷิॿπʔϧͷϕετϓϥΫςΟε (@usamik26) - iOSDC 2016 14
  6. ԿΛ͢Δπʔϧʁ » ΞϓϦ಺ͷը૾΍ςΩετͷѻָ͍͕ʹͳΔίʔυΛ ੜ੒ͯ͘͠ΕΔ // πʔϧͳ͠ͷ৔߹ let image = UIImage(named:

    "banana") // SwiftGen Λ࢖ͬͨ৔߹ let image = UIImage(asset: .Banana) iOS ΞϓϦ։ൃͷิॿπʔϧͷϕετϓϥΫςΟε (@usamik26) - iOSDC 2016 17
  7. Bad Practice ςΩετΛιʔείʔυʹ௚઀ॻ͘ label.text = "͜Μʹͪ͸" » දࣔςΩετ͕Ͳ͜Ͱࢦఆ͞Ε͍ͯΔ͔෼͔Γʹ͍͘ » ݕࡧͮ͠Β͍

    » ैͬͯɺमਖ਼ͮ͠Β͍ʢಛʹޙͰमਖ਼͢Δͱ͖ʣ » ϩʔΧϥΠζͷͱ͖ʹࠔΔ iOS ΞϓϦ։ൃͷิॿπʔϧͷϕετϓϥΫςΟε (@usamik26) - iOSDC 2016 18
  8. Good Practice 1 ςΩετΛ strings ϑΝΠϧʹஔ͘ label.text = NSLocalizedString("label_hello") »

    දࣔςΩετ͕Ͳ͜Ͱࢦఆ͞Ε͍ͯΔ͔෼͔Γ΍͍͢ » ݕࡧ͠΍͍͢ » ϩʔΧϥΠζͷͱ͖ʹָʹͳΔ » ͨͩ͠ɺςΩετΛ strings ʹஔ͘ͷ͕໘౗ͳؾ࣋ ͪ͸͋Δʢ৺ཧతෛ୲ʣ iOS ΞϓϦ։ൃͷิॿπʔϧͷϕετϓϥΫςΟε (@usamik26) - iOSDC 2016 19
  9. Good Practice 2 ϦιʔεऔΓࠐΈπʔϧΛ࢖͏ // SwiftGen ͷ৔߹ label.text = tr(.LabelHello)

    » strings ͷΩʔจࣈྻͷϛε͕ͳ͘ͳΔ » ίϯύΠϧ࣌ʹνΣοΫ͞ΕΔ » ςΩετΛ strings ʹஔ͘৺ཧతෛ୲ͷܰݮ » ίʔυ͕ॻ͖΍͘͢ͳΔͷ͔ͩΒ΍͓ͬͯ͜͏ iOS ΞϓϦ։ൃͷิॿπʔϧͷϕετϓϥΫςΟε (@usamik26) - iOSDC 2016 20
  10. Bad Practice ίʔυνΣοΫΛ࣮ߦ͠ͳ͍ » ڊେͳΫϥε » ෼ذ͕ଟ͗͢Δϝιου » ෆద੾ͳ force

    cast iOS ΞϓϦ։ൃͷิॿπʔϧͷϕετϓϥΫςΟε (@usamik26) - iOSDC 2016 24
  11. Good Practice 2 Ϗϧυ࣌ʹࣗಈతʹίʔυνΣοΫ » Build Phase ʹπʔϧ࣮ߦΛೖΕΔ » πʔϧͷ࣮ߦΛ๨Εͣʹ͢Ή

    » Warning / Error දࣔ͞ΕΔͷͰରԠָ͕ iOS ΞϓϦ։ൃͷิॿπʔϧͷϕετϓϥΫςΟε (@usamik26) - iOSDC 2016 26
  12. ิ଍ طଘͷϓϩδΣΫτʹಋೖ͢Δʹ͸ » طଘϓϩδΣΫτʹಋೖ͢ΔͱϏοΫϦ͢Δ΄Ͳଟ͘ ͷ Warning / Error ͕ग़Δ »

    ͦΕͰ΋ಋೖ͸ͨ͠ํ͕͍͍ » νΣοΫϧʔϧΛܰݮͯ͠Ͱ΋ಋೖ͓ͯ͘͠ » ͍ͬͨΜಋೖͯ͠͠·͑͹৺ཧతෛ୲͕ܰ͘ͳΔ iOS ΞϓϦ։ൃͷิॿπʔϧͷϕετϓϥΫςΟε (@usamik26) - iOSDC 2016 27
  13. Good Practice ίʔυνΣοΫͷ݁Ռʹ͙͢ରॲ͢Δ » ৗʹ Warning Λͳ͘͢ » ରॲ͢΂͖ Warning

    Λݟམͱ͞ͳ͍ » Warning ʹରॲ͢Δͷ͕େมͳΒɺ͍ͬͦͷ͜ͱν ΣοΫϧʔϧΛܰݮͯ͠͠·͏ » ίʔυνΣοΫΛܧଓ͢Δ΄͏͕େࣄ iOS ΞϓϦ։ൃͷิॿπʔϧͷϕετϓϥΫςΟε (@usamik26) - iOSDC 2016 29
  14. Bad Practice ίʔυϑΥʔϚοτΛߦΘͳ͍ » ΧοίͷҐஔͱ͔εϖʔεͷೖΕํͱ͔όϥόϥ » ϧʔϧ͕͋ͬͯ΋कΔͷ͸େม » ϑΥʔϚοτͷϧʔϧΛ͍֮͑ͯͳ͍ͱμϝ »

    ͏͔ͬΓΦϨΦϨϧʔϧͰॻ͍ͯ͠·͏ iOS ΞϓϦ։ൃͷิॿπʔϧͷϕετϓϥΫςΟε (@usamik26) - iOSDC 2016 30
  15. Good Practice ίʔυϑΥʔϚοτΛπʔϧͰߦ͏ » ྫɿSwiftLint ͳΒ swiftlint autocorrect » ΧοίͷҐஔͱ͔εϖʔεͷͷೖΕํͱ͔উखʹमਖ਼

    ͞ΕΔ » ϑΥʔϚοτͷϧʔϧ͸๨ΕΑ͏ » πʔϧʹ೚ͤΑ͏ iOS ΞϓϦ։ൃͷิॿπʔϧͷϕετϓϥΫςΟε (@usamik26) - iOSDC 2016 31