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

Share Xcode Templates
 with team

Share Xcode Templates
 with team

テンプレートの作成と共有を簡単にしよう

https://github.com/ngtk/xcode-template

Kento Nagata

May 23, 2018
Tweet

More Decks by Kento Nagata

Other Decks in Technology

Transcript

  1. ©2018 Wantedly, Inc.
    Share Xcode Templates

    with team
    potatotips #51

    23.May.2018 - @ngtk, Kento Nagata
    ςϯϓϨʔτͷ࡞੒ͱڞ༗Λ؆୯ʹ͠Α͏

    View full-size slide

  2. ©2018 Wantedly, Inc.
    Ӭా݈ਓ
    8BOUFEMZ *OD&OHJOFFS
    !OHULOU !OHUL
    • Wantedly VisitͷΞϓϦΛ։ൃ͍ͯ͠·͢
    • Swift/iOS։ൃΛ͸͡Ίͯ5ϲ݄͘Β͍
    • ͦͷલ͸Rails, React, Reduxͱ͔΢Σϒͷ։ൃΛ΍͍ͬͯͨਓ
    • Potatotips͸લճʹଓ͖2ճ໨ ☺

    View full-size slide

  3. ©2018 Wantedly, Inc.
    XcodeͷςϯϓϨʔτػೳ

    ࢖ͬͨ͜ͱ͋Γ·͔͢ʁ

    View full-size slide

  4. ©2018 Wantedly, Inc.
    ҰൠʹɺςϯϓϨʔτػೳ͸

    ڞ௨ͷهड़Λॻ͔ͣʹࡁΉͷͰੜ࢈త

    View full-size slide

  5. ©2018 Wantedly, Inc.
    ΋ͪΖΜɺ

    ϓϩτίϧΤΫεςϯγϣϯ

    ίʔυࣗಈੜ੒

    ͳͲίʔυʹΑΔڞ௨ԽʹΑͬͯهड़ྔΛ

    ݮΒ͢͜ͱ͕લఏͰɺ

    ࢒Δஆ͔ຯ͕ςϯϓϨʔτ

    View full-size slide

  6. ©2018 Wantedly, Inc.
    XcodeͰ͸Ͳ͏ͳͷ͔ʁ

    View full-size slide

  7. ©2018 Wantedly, Inc.
    How to use Xcode template
    New File
    FIle > New > File…⌘N͔Β৽ن࡞੒͢Δͱ͖ʹબ΂
    Δɻ

    View full-size slide

  8. ©2018 Wantedly, Inc.
    How to use Xcode template
    File Template Library
    XcodeͷӈԼʹ͋Δ΍ͭɺ͔͜͜Βυϥοάͯ͠ࠨ
    ΧϥϜͷσΟϨΫτϦ(Project Navigator)ʹυϩο
    ϓ͢Δͱ࡞੒Ͱ͖Δɻ

    View full-size slide

  9. ©2018 Wantedly, Inc.
    Αͦ͞͏Ͱ͢Ͷʂ

    View full-size slide

  10. ©2018 Wantedly, Inc.
    ͨͩ͠ɺΧελϜͰ௥Ճ͢Δํ๏΍

    ϓϩδΣΫτͰڞ༗͢Δํ๏͸ɺ

    ެࣜͷυΩϡϝϯτ͕ͳ͍ͨΊ
    ෼͔ΓͮΒ͍…

    View full-size slide

  11. ©2018 Wantedly, Inc.
    ͔͠΋ɺProject΍WorkspaceͰ

    ڞ༗͢Δ࢓૊Έ͸ఏڙ͞Ε͍ͯͳ͍

    View full-size slide

  12. ©2018 Wantedly, Inc.
    ڞ༗͢Δ࢓૊ΈΛ࡞Δ

    View full-size slide

  13. ©2018 Wantedly, Inc.
    1. ৽ن௥Ճ:

    ϓϦηοτͰ༻ҙ͞Ε͍ͯΔ΋ͷΛίϐϖͯ͠
    ࡞੒
    2. ڞ༗ํ๏:

    ϦϙδτϦʹνΣοΫΠϯͯ͠ɺ

    ద੾ͳ৔ॴʹϦϯΫ͢ΔεΫϦϓτΛॻ͘
    ΍Δ΂͖͜ͱ

    View full-size slide

  14. ©2018 Wantedly, Inc.
    ϓϦηοτͷςϯϓϨʔτ(Swift File)Λ

    ϦϙδτϦʹίϐʔͯ͠௥Ճ
    A"QQMJDBUJPOT9DPEFBQQ$POUFOUT%FWFMPQFS-JCSBSZ9DPEF
    5FNQMBUFT'JMFa5FNQMBUFT4PVSDF4XJGUa'JMFYDUFNQMBUFA

    View full-size slide

  15. ©2018 Wantedly, Inc.

    View full-size slide

  16. ©2018 Wantedly, Inc.
    ___FILEBASENAME___.swift

    View full-size slide

  17. ©2018 Wantedly, Inc.
    TemplateInfo.plist

    View full-size slide

  18. ©2018 Wantedly, Inc.
    ςϯϓϨʔτϑΝΠϧΛ

    ద੾ͳ৔ॴʹ഑ஔ͢Δ

    εΫϦϓτΛॻ͘

    View full-size slide

  19. ©2018 Wantedly, Inc.
    ద੾ͳ৔ॴ
    A)0.&-JCSBSZ%FWFMPQFS9DPEF5FNQMBUFTA

    View full-size slide

  20. ©2018 Wantedly, Inc.
    ೉͍͠ʂ

    View full-size slide

  21. ©2018 Wantedly, Inc.
    #!/bin/bash
    project_template_dir=$(cd $(dirname ${BASH_SOURCE:-$0})/../Templates; pwd)
    global_template_dir="$HOME/Library/Developer/Xcode/Templates"
    global_project_template_dir="$global_template_dir/visit-ios"
    function main() {
    prepare
    link_project_to_global
    echo ""
    echo "Installed✨ "
    echo ""
    show_instruction
    }
    function prepare() {
    if [ ! -e $global_template_dir ]; then
    mkdir -p $global_template_dir
    echo "+ Created template directory: $global_template_dir"
    fi
    }
    function link_project_to_global() {
    if [ -e "$global_project_template_dir" ]; then
    echo "Alread linked. $global_project_template_dir"
    echo ""
    show_instruction
    exit 1
    fi
    ln -s $project_template_dir $global_project_template_dir
    echo "+ Linked to $global_project_template_dir"
    }
    function show_instruction() {
    echo "You can use it from \"File Template Library\"."
    echo ""
    echo " Xcode > View > Utilities > Show File Template Library"
    echo ""
    }
    main
    Install-template

    View full-size slide

  22. ©2018 Wantedly, Inc.
    ͋ͱ͸ΈΜͳʹ࣮ߦͯ͠΋Β͏͚ͩʂ

    View full-size slide

  23. ©2018 Wantedly, Inc.
    ΊͰͨ͠ɺΊͰͨ͠ʂ ✨

    View full-size slide

  24. ©2018 Wantedly, Inc.
    Μɺͪΐͬͱ଴ͬͯ

    View full-size slide

  25. ©2018 Wantedly, Inc.
    ͜Ε৽͘͠ςϯϓϨʔτ௥Ճ͢Δͷ

    ΊΜͲ͘͘͞ͳ͍ʁ

    View full-size slide

  26. ©2018 Wantedly, Inc.
    ଞͷϓϩδΣΫτͰ

    ࠶ݱͮ͠Β͍Α͏ͳ…

    View full-size slide

  27. ©2018 Wantedly, Inc.
    ͱ͍͏͜ͱͰɺίϚϯυʹ͠·ͨ͠

    View full-size slide

  28. ©2018 Wantedly, Inc.
    “xcode-template”
    ςϯϓϨʔτͷ࡞੒ͱڞ༗Λ؆୯ʹ
    IUUQTHJUIVCDPNOHULYDPEFUFNQMBUF

    View full-size slide

  29. ©2018 Wantedly, Inc.
    $ brew install ngtk/tools/xcode-template
    )PNFCSFXͰΠϯετʔϧͰ͖·͢
    IUUQTHJUIVCDPNOHULYDPEFUFNQMBUF

    View full-size slide

  30. ©2018 Wantedly, Inc.
    $ xctemplate g UIViewController
    ςϯϓϨʔτΛ࡞੒ͯ͠ɺϓϩδΣΫτ಺ʹ഑ஔ

    IUUQTHJUIVCDPNOHULYDPEFUFNQMBUF

    View full-size slide

  31. ©2018 Wantedly, Inc.
    $ xctemplate link
    9DPEFͰར༻Մೳʹ͢Δ

    IUUQTHJUIVCDPNOHULYDPEFUFNQMBUF

    View full-size slide

  32. ©2018 Wantedly, Inc.

    View full-size slide

  33. ©2018 Wantedly, Inc.
    ੋඇɺ࢖ͬͯΈ͍ͯͩ͘͞

    View full-size slide

  34. ©2018 Wantedly, Inc.
    ·ͱΊ

    View full-size slide

  35. ©2018 Wantedly, Inc.
    1. ςϯϓϨʔτΛ࢖ͬͯޮ཰Խ͠Α͏
    • ͦͷલʹίʔυͰͰ͖Δڞ௨Խ͸΍Ζ͏ʂ
    2. νʔϜͰڞ༗͠Α͏
    3. xcode-templateͰ؆୯ʹ࡞੒ɾڞ༗Ͱ͖ΔΑ
    • https://github.com/ngtk/xcode-template
    • ࠓ೔࡞ͬͯ·ͩࡶͳͱ͜Ζ͕ଟ͍ͷͰɺ͜ͷޙ΋͏ͪΐͬͱؤுΓ·͢
    ·ͱΊ

    View full-size slide

  36. ©2018 Wantedly, Inc.
    Thank you! ☺

    View full-size slide