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

Swift Package Manager によるマルチモジュール構成

Swift Package Manager によるマルチモジュール構成

2021/9/10 に開催された「みそかつモバイル#1」での発表資料です
https://misokatsu-web.connpass.com/event/221035/

Tomoki Kobayashi

September 10, 2021
Tweet

More Decks by Tomoki Kobayashi

Other Decks in Programming

Transcript

  1. !UFNPLJ
    4XJGU1BDLBHF.BOBHFSʹΑΔ
    ϚϧνϞδϡʔϧߏ੒
    Έ͔ͦͭϞόΠϧ

    View full-size slide

  2. 5PNPLJ,PCBZBTIJ
    !UFNPLJ
    w גࣜձࣾελϝϯʢ໊ݹ԰ʣ
    w ΤϯδχΞϦϯάɾϚωʔδϟʔ
    w J1IPOF(೔ຊ্཮ͱಉ࣌ʹ

    J1IPOFΞϓϦ։ൃΛ࢝ΊΔ
    w "OESPJE 'MVUUFSʹ΋खΛग़͢

    View full-size slide

  3. 📖΃ΒΓදࢴͰݟ͚ͭΔֆຊ԰͞ΜΞϓϦ
    'MVUUFSͰJ04"OESPJE8FCΞϓϦΛϦϦʔεʂ
    https://perali.hiraku.space/about

    View full-size slide

  4. 9DPEFͷϞδϡʔϧ

    View full-size slide

  5. import UIKit
    import SwiftUI
    👈ίϨ

    View full-size slide

  6. ϞδϡʔϧΛ෼͚ΔϝϦοτɾσϝϦοτ
    w ✅ଞͷϞδϡʔϧ΁ͷެ։ൣғΛίϯτϩʔϧͰ͖Δ
    w ✅Ϟδϡʔϧ୯ҐͰͷϏϧυʹΑΓϏϧυ͕࣌ؒ୹ॖ͞ΕΔ
    w ❌ద੾ʹϞδϡʔϧΛ෼ׂ͢Δ೉қ౓͕ߴ͍
    w ❌ϞδϡʔϧؒΛૄ݁߹ʹ͢ΔͨΊͷந৅ԽʹΑΓෳࡶ্͕͕͞Δ

    View full-size slide


  7. ;PPϞδϡʔϧΛఆٛ

    View full-size slide


  8. ;PPϞδϡʔϧΛ࢖͏

    View full-size slide

  9. 9DPEFͷϚϧνϞδϡʔϧߏ੒

    View full-size slide

  10. .VMUJ5BSHFUT
    9DPEFϓϩδΣΫτͷதʹෳ਺ͷλʔήοτ

    View full-size slide

  11. .VMUJ1SPKFDUT
    9DPEFϫʔΫεϖʔεͷதʹෳ਺ͷ9DPEFϓϩδΣΫτ

    View full-size slide

  12. 9DPEF1SPKFDUϑΝΠϧͱͷ
    ಆ͍͕େมͳ͜ͱʹʜ

    View full-size slide

  13. 9DPEF1SPKFDUϑΝΠϧͱͷ
    ಆ͍͕େมͳ͜ͱʹʜ

    View full-size slide

  14. 🆕.VMUJ-PDBM4XJGU1BDLBHFT

    View full-size slide

  15. 🆕.VMUJ-PDBM4XJGU1BDLBHFT
    9DPEFϓϩδΣΫτͷதʹϩʔΧϧ؅ཧͷ4XJGUύοέʔδΛෳ਺഑ஔ

    View full-size slide

  16. .VMUJ-PDBM4XJGU1BDLBHFTߏ੒ͷ࡞Γํ
    ᶃΞϓϦ༻ͷ9DPEFϓϩδΣΫτΛ༻ҙ
    MyApp
    MyApp.xcodeproj
    MyApp
    􀆈
    􀆊

    View full-size slide

  17. .VMUJ-PDBM4XJGU1BDLBHFTߏ੒ͷ࡞Γํ
    ᶄMJCSBSZλΠϓͷ4XJGUύοέʔδΛ࡞Δ
    MyApp
    MyApp.xcodeproj
    MyApp
    􀆈
    􀆊
    ModuleA
    􀆊
    mkdir ModuleA
    cd $_
    swift package init

    View full-size slide

  18. .VMUJ-PDBM4XJGU1BDLBHFTߏ੒ͷ࡞Γํ
    ᶅύοέʔδͷσΟϨΫτϦΛ9DPEFͷ1SPKFDU/BWJHBUPS΁υϩοϓ
    MyApp
    MyApp.xcodeproj
    MyApp
    􀆈

    ModuleA

    ModuleA
    􀅼

    View full-size slide

  19. .VMUJ-PDBM4XJGU1BDLBHFTߏ੒ͷ࡞Γํ
    ᶆ௥Ճͨ͠ύοέʔδΛΞϓϦͷϦϯΫର৅ʹઃఆ͢Δ
    MyApp
    MyApp.xcodeproj
    MyApp
    􀆈

    ModuleA

    View full-size slide

  20. .VMUJ-PDBM4XJGU1BDLBHFTߏ੒ͷ࡞Γํ
    ᶇύοέʔδؒͷґଘؔ܎͸1BDLBHFTXJGUʹఆٛ
    MyApp
    MyApp.xcodeproj
    MyApp
    􀆈

    ModuleA

    ModuleB

    ґଘ

    View full-size slide

  21. ✅Ϟδϡʔϧͷઃఆ͸1BDLBHFTXJGU΁
    9DPEFϓϩδΣΫτϑΝΠϧʹൺ΂ͯѹ౗తʹ؆ܿʹʂ
    ෳ਺ਓ։ൃͰͷίϯϑϦΫτͷۤ௧΋αϤ΢φϥ👋

    View full-size slide

  22. ✅Ϟδϡʔϧ୯ҐͰͷܰྔͳ։ൃ
    4XJGUύοέʔδͷΈ9DPEFͰ։͍ͯ։ൃ͢Ε͹Ϗϧυ΋αΫαΫಈ͘ʂ

    View full-size slide

  23. '"2ʢࢲ͕ࠔͬͯௐ΂ͨ͜ͱʣ

    View full-size slide

  24. 4XJGU6*ͷϓϨϏϡʔදࣔ͸Ͱ͖·͔͢ʁ
    ✅Ͱ͖·͢ʂͨͩ͠4XJGU6*͕ར༻Ͱ͖Δ1MBUGPSNͷࢦఆ͕ඞਢɻ
    ·ͨɺϓϨϏϡʔ༻ʹ࢖͏1SFWJFX$POUFOUʹ૬౰͢Δػೳ͕ͳͦ͞͏ɻ
    9DPEF1SFWJFXΛ࢖༻͢Δ৔߹͸
    4XJGU6*͕ར༻Ͱ͖Δ1MBUGPSN͕ඞਢ

    View full-size slide

  25. ύοέʔδʹϦιʔε΋ؚΊΒΕ·͔͢ʁ
    ✅Ͱ͖·͢ʂYDBTTFUT TUPSZCPBSE TUSJOHTͱ͍ͬͨҰൠతͳ
    ϦιʔεϑΝΠϧ͸ࣗಈతʹύοέʔδͷ#VOEMFʹಉࠝ͞Ε·͢ɻ
    ϩʔΧϥΠζɾϦιʔεΛؚΉ৔߹͸
    EFGBVMU-PDBMJ[BUJPOͷઃఆΛʂ
    ͦͷଞͷϦιʔεϑΝΠϧ͸
    5BSHFUʹ໌͍ࣔͯͩ͘͠͞

    View full-size slide

  26. JG%(Ͱσόοά࣌ͷίʔυΛॻ͚·͔͢ʁ
    ✅ॻ͚·͢ʂಠࣗͷίϯύΠϧ࣌ϑϥά΋1BDLBHFTXJGUʹఆٛͰ͖·͢ɻ

    View full-size slide

  27. ύοέʔδϏϧυ࣌ʹ4XJGU-JOUΛ࣮ߦ͍ͨ͠ʂ
    ❌Ͱ͖·ͤΜʂ
    w 9DPEFϓϩδΣΫτͷ#VJME1IBTF4DSJQU૬౰ͷ࢓૊Έ͕͋Γ·ͤΜ
    w 4DIFNFͷ#VJME1SF"DUJPOͰ͸9DPEFͰ-JOU݁ՌΛͰදࣔͰ͖·ͤΜ

    TXJGUMJOUŠ
    fi
    YͷΈͳΒ0,ʣ
    w ΞϓϦຊମϓϩδΣΫτͷϏϧυ࣌ʹҰׅνΣοΫ͢Δ͔͠ͳ͍ͷ͔ʁ

    View full-size slide

  28. ·ͱΊ
    w ΞϓϦ։ൃʹ͓͍ͯϩʔΧϧ؅ཧͷ4XJGUύοέʔδͰ

    ϚϧνϞδϡʔϧߏ੒Λ࣮ݱͰ͖Δ
    w 9DPEFϓϩδΣΫτʹΑΔϚϧνϞδϡʔϧߏ੒ΑΓ΋ɺ
    1BDLBHFTXJGUʹΑΓγϯϓϧʹ؅ཧͰ͖Δ
    w 9DPEFϓϩδΣΫτͱͷҧ͍Λ೺Ѳ͓ͯ͘͠ඞཁ͕͋Δ

    View full-size slide