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

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

0b8ad408b31cb9d5cff2828086c65d58?s=47 temoki
September 10, 2021

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

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

0b8ad408b31cb9d5cff2828086c65d58?s=128

temoki

September 10, 2021
Tweet

Transcript

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

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

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

  4. 9DPEFͷϞδϡʔϧ

  5. import UIKit import SwiftUI 👈ίϨ

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

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

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

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

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

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

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

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

  14. 🆕.VMUJ-PDBM4XJGU1BDLBHFT

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

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

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

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

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

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

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

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

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

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

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

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

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

    w ΞϓϦຊମϓϩδΣΫτͷϏϧυ࣌ʹҰׅνΣοΫ͢Δ͔͠ͳ͍ͷ͔ʁ
  28. ·ͱΊ

  29. ·ͱΊ w ΞϓϦ։ൃʹ͓͍ͯϩʔΧϧ؅ཧͷ4XJGUύοέʔδͰ 
 ϚϧνϞδϡʔϧߏ੒Λ࣮ݱͰ͖Δ w 9DPEFϓϩδΣΫτʹΑΔϚϧνϞδϡʔϧߏ੒ΑΓ΋ɺ 1BDLBHFTXJGUʹΑΓγϯϓϧʹ؅ཧͰ͖Δ w 9DPEFϓϩδΣΫτͱͷҧ͍Λ೺Ѳ͓ͯ͘͠ඞཁ͕͋Δ