$30 off During Our Annual Pro Sale. View Details »

XcodeのDevelopment Assets探訪

Sho Ikeda
October 31, 2022

XcodeのDevelopment Assets探訪

「potatotips #79 iOS/Android開発Tips共有会」での発表資料です #potatotips

https://potatotips.connpass.com/event/261215/

Sho Ikeda

October 31, 2022
Tweet

More Decks by Sho Ikeda

Other Decks in Programming

Transcript

  1. Xcodeͷ Development Assets ୳๚ @ikesyo / Sho Ikeda potatotips #79

    2022-10-31 Mon #potatotips
  2. @ikesyo / Sho Ikeda • ͍͚͠ΐʔʗ஑ా ᠳ • גࣜձࣾ͸ͯͳ γχΞΤϯδχΞʢژ౎ʣ

    • ϚϯΨΞϓϦνʔϜ • iOS / Android / React Native • Swiftίϛολʔ • swift-corelibs-foundation • Quick/Nimbleͷϝϯςφʔ • ࠷ۙ͸ٳࢭؾຯ…… • https://twitter.com/ikesyo • https://github.com/ikesyo
  3. ීஈ͸ϚϯΨΞϓϦΛ࡞͍ͬͯ·͢ • ʮGigaViewer for AppsʯͰϚϯΨͷະདྷΛ޿͍͛ͨ - ࠾༻৘ใ - גࣜձࣾ͸ͯͳ

  4. ීஈ͸ϚϯΨΞϓϦΛ࡞͍ͬͯ·͢ • νʔϜϝϯόʔͷΞ΢τϓοτ • ϚϯΨϏϡʔϫGigaViewer for AppsͰJetpack ComposeΛશ໘࠾༻ͯ͠Έͨ - Hatena

    Developer Blog • GigaViewer for AppsͰ࢖͍ͬͯΔศརSwiftUIίϯϙʔωϯτ̑࿈ൃʂ - Hatena Developer Blog
  5. Xcodeͷ Development Assets ୳๚

  6. Development Assets • Xcode 11ͰSwiftUIͱڞʹొ৔ͨ͠ػೳ • SwiftUIͷϓϨϏϡʔʹ࢖͏ը૾ϦιʔεͳͲͷΞηοτͷύεΛࢦఆ͢Δ • ΞηοτΧλϩά΍JSONσʔλͳͲͷϦιʔε͚ͩͰͳ͘ɺιʔείʔ υʹ΋࢖͑Δ

    • ͜͜Ͱࢦఆͨ͠ίϯςϯπ͸։ൃ൛ͷΞϓϦʹؚ͔͠·Εͳ͍ • ϓϨϏϡʔ༻ͷը૾Ϧιʔε΍μϛʔσʔλΛ࡞ΔίʔυͳͲΛ੡඼ ൛ͷΞϓϦʢϏϧυʣʹؚΊͣʹࡁΉ
  7. Development Assets • λʔήοτͷઃఆͷGeneralͷ࠷Լ෦ͷ Development Assets • SwiftUIͷϓϩδΣΫτΛ৽ن࡞੒͢Δ ͱ $λʔήοτ໊/Preview

    Content ͱ͍͏ύεͱɺͦͷதʹ Preview Assets ͱ͍͏ΞηοτΧλϩά͕σ ϑΥϧτͰ༻ҙ͞Ε͍ͯΔ • σΟϨΫτϦ୯ҐͰ΋ɺϑΝΠϧ୯Ґ Ͱ΋ࢦఆͰ͖Δ
  8. ։ൃ൛ͷΞϓϦͱ͸ https://developer.apple.com/documentation/xcode/build- settings-reference#Development-Assets Development Assets Setting name: DEVELOPMENT_ASSET_PATHS ɹ Files

    and directories used only for development. Archive and install builds will exclude this content.
  9. ։ൃ൛ͷΞϓϦͱ͸ • archiveϏϧυʢͱinstallϏϧυʣͷ࣌ ʹ͸Ϗϧυର৅͔Βআ֎͞ΕΔ • xcodebuild ͷ archive ΞΫγϣϯ ͱ

    install ΞΫγϣϯ • XcodeͷGUI্Ͱ͸ArciveͷΈ • DebugϏϧυͰͷΈ༗ޮͳ༁Ͱ͸ͳ͍ • DebugϏϧυ͚ͩʹߜΓ͍ͨιʔ είʔυʹ͸ #if DEBUG ... #endif ͕ඞཁ
  10. XcodeGen • Development Assetsͷ࣮ଶ͸ DEVELOPMENT_ASSET_PATHS ͱ͍͏Ϗϧυઃఆ • XcodeGenͰ࢖͏ʹ͸ࢦఆ͍ͨ͠λʔήοτͰͦͷϏϧυઃఆΛࢦఆ͢Ε͹ Α͍ targets:

    Foo: ... settings: base: DEVELOPMENT_ASSET_PATHS: - Foo/Preview Content
  11. ༻్ • ϓϨϏϡʔ༻ͷը૾ϦιʔεʢΞηοτΧλϩάʣ • ϓϨϏϡʔ༻ͷμϛʔσʔλ • APIϨεϙϯεͷJSON • μϛʔσʔλΛ࡞Δίʔυ •

    ϞοΫ • ...
  12. ϞοΫ • uber/MockoloͳͲʹΑΔϞοΫੜ੒͸ɺςετλʔήοτͰߦ ͍ɺςετίʔυͰར༻͢Δͷ͕ҰൠతͩͱࢥΘΕΔ͕ • ViewͷϓϨϏϡʔͷͨΊʹViewModel͕ඞཁͰɺViewModelͷ ੜ੒ʹ͸ґଘੑͷprotocolͷ࣮ମ͕ඞཁͰɺϓϨϏϡʔ༻ʹ͸ ϞοΫΛ࢖͍͍ͨͱ͍͏έʔε • Կ΋͠ͳ͍

    • μϛʔσʔλΛฦ͢
  13. ϞοΫ • ϞοΫΛςετλʔήοτͰ͸ͳ͘ɺϝΠϯλʔήοτʹؚΊΔ͜ͱͰɺϞοΫΛ ϓϨϏϡʔͰ΋ར༻Ͱ͖Δ • ϞοΫੜ੒ʢͷεΫϦϓτϏϧυϑΣʔζͳͲʣΛϝΠϯλʔήοτଆͰ࣮ߦ͢ Δ • ੜ੒͞ΕͨϞοΫͷιʔείʔυʢΛؚΉσΟϨΫτϦʣΛDevelopment Assetsʹࢦఆ͢Δ

    • ϞοΫ͕੡඼൛ʹؚ·Εͳ͍͜ͱΛอূͰ͖Δ • ϞοΫͷੜ੒ίʔυΛϓϨϏϡʔ΍ςετίʔυҎ֎Ͱར༻͍ͯ͠Ε͹archive ࣌ʹϏϧυΤϥʔʹͳΔ
  14. ·ͱΊ • Development Assetsͱ͸ • Development Assetsͷ࢖͍ํ • ը૾ϦιʔεʢΞηοτΧλϩάʣҎ֎ͷ༻్ •

    ϞοΫΛςετ͚ͩͰͳ͘ϓϨϏϡʔʹ΋࢖͏
  15. ࢀߟࢿྉ • Mastering Xcode Previews - WWDC19 - Videos -

    Apple Developer • طଘϓϩδΣΫτͰ SwiftUI ͷϓϨϏϡʔػೳΛ࢖͏ Using SwiftUI preview in existing project - ObjecTips • Structure your app for SwiftUI previews - WWDC20 - Videos - Apple Developer • ๩͍͠ਓ޲͚ͷ Structure your app for SwiftUI previews - #WWDC20ʛށըඒ֯ʛnote
  16. ! Happy Development

  17. Thank you @ikesyo / Sho Ikeda