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

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

    View full-size slide

  2. @ikesyo / Sho Ikeda
    • ͍͚͠ΐʔʗ஑ా ᠳ
    • גࣜձࣾ͸ͯͳ γχΞΤϯδχΞʢژ౎ʣ
    • ϚϯΨΞϓϦνʔϜ
    • iOS / Android / React Native
    • Swiftίϛολʔ
    • swift-corelibs-foundation
    • Quick/Nimbleͷϝϯςφʔ
    • ࠷ۙ͸ٳࢭؾຯ……
    • https://twitter.com/ikesyo
    • https://github.com/ikesyo

    View full-size slide

  3. ීஈ͸ϚϯΨΞϓϦΛ࡞͍ͬͯ·͢
    • ʮGigaViewer for AppsʯͰϚϯΨͷະདྷΛ޿͍͛ͨ - ࠾༻৘ใ - גࣜձࣾ͸ͯͳ

    View full-size slide

  4. ීஈ͸ϚϯΨΞϓϦΛ࡞͍ͬͯ·͢
    • νʔϜϝϯόʔͷΞ΢τϓοτ
    • ϚϯΨϏϡʔϫGigaViewer for AppsͰJetpack ComposeΛશ໘࠾༻ͯ͠Έͨ - Hatena Developer Blog
    • GigaViewer for AppsͰ࢖͍ͬͯΔศརSwiftUIίϯϙʔωϯτ̑࿈ൃʂ - Hatena Developer Blog

    View full-size slide

  5. Xcodeͷ
    Development Assets
    ୳๚

    View full-size slide

  6. Development Assets
    • Xcode 11ͰSwiftUIͱڞʹొ৔ͨ͠ػೳ
    • SwiftUIͷϓϨϏϡʔʹ࢖͏ը૾ϦιʔεͳͲͷΞηοτͷύεΛࢦఆ͢Δ
    • ΞηοτΧλϩά΍JSONσʔλͳͲͷϦιʔε͚ͩͰͳ͘ɺιʔείʔ
    υʹ΋࢖͑Δ
    • ͜͜Ͱࢦఆͨ͠ίϯςϯπ͸։ൃ൛ͷΞϓϦʹؚ͔͠·Εͳ͍
    • ϓϨϏϡʔ༻ͷը૾Ϧιʔε΍μϛʔσʔλΛ࡞ΔίʔυͳͲΛ੡඼
    ൛ͷΞϓϦʢϏϧυʣʹؚΊͣʹࡁΉ

    View full-size slide

  7. Development
    Assets
    • λʔήοτͷઃఆͷGeneralͷ࠷Լ෦ͷ
    Development Assets
    • SwiftUIͷϓϩδΣΫτΛ৽ن࡞੒͢Δ
    ͱ $λʔήοτ໊/Preview Content
    ͱ͍͏ύεͱɺͦͷதʹ Preview
    Assets ͱ͍͏ΞηοτΧλϩά͕σ
    ϑΥϧτͰ༻ҙ͞Ε͍ͯΔ
    • σΟϨΫτϦ୯ҐͰ΋ɺϑΝΠϧ୯Ґ
    Ͱ΋ࢦఆͰ͖Δ

    View full-size slide

  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.

    View full-size slide

  9. ։ൃ൛ͷΞϓϦͱ͸
    • archiveϏϧυʢͱinstallϏϧυʣͷ࣌
    ʹ͸Ϗϧυର৅͔Βআ֎͞ΕΔ
    • xcodebuild ͷ archive ΞΫγϣϯ
    ͱ install ΞΫγϣϯ
    • XcodeͷGUI্Ͱ͸ArciveͷΈ
    • DebugϏϧυͰͷΈ༗ޮͳ༁Ͱ͸ͳ͍
    • DebugϏϧυ͚ͩʹߜΓ͍ͨιʔ
    είʔυʹ͸ #if DEBUG ...
    #endif ͕ඞཁ

    View full-size slide

  10. XcodeGen
    • Development Assetsͷ࣮ଶ͸ DEVELOPMENT_ASSET_PATHS ͱ͍͏Ϗϧυઃఆ
    • XcodeGenͰ࢖͏ʹ͸ࢦఆ͍ͨ͠λʔήοτͰͦͷϏϧυઃఆΛࢦఆ͢Ε͹
    Α͍
    targets:
    Foo:
    ...
    settings:
    base:
    DEVELOPMENT_ASSET_PATHS:
    - Foo/Preview Content

    View full-size slide

  11. ༻్
    • ϓϨϏϡʔ༻ͷը૾ϦιʔεʢΞηοτΧλϩάʣ
    • ϓϨϏϡʔ༻ͷμϛʔσʔλ
    • APIϨεϙϯεͷJSON
    • μϛʔσʔλΛ࡞Δίʔυ
    • ϞοΫ
    • ...

    View full-size slide

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

    View full-size slide

  13. ϞοΫ
    • ϞοΫΛςετλʔήοτͰ͸ͳ͘ɺϝΠϯλʔήοτʹؚΊΔ͜ͱͰɺϞοΫΛ
    ϓϨϏϡʔͰ΋ར༻Ͱ͖Δ
    • ϞοΫੜ੒ʢͷεΫϦϓτϏϧυϑΣʔζͳͲʣΛϝΠϯλʔήοτଆͰ࣮ߦ͢
    Δ
    • ੜ੒͞ΕͨϞοΫͷιʔείʔυʢΛؚΉσΟϨΫτϦʣΛDevelopment
    Assetsʹࢦఆ͢Δ
    • ϞοΫ͕੡඼൛ʹؚ·Εͳ͍͜ͱΛอূͰ͖Δ
    • ϞοΫͷੜ੒ίʔυΛϓϨϏϡʔ΍ςετίʔυҎ֎Ͱར༻͍ͯ͠Ε͹archive
    ࣌ʹϏϧυΤϥʔʹͳΔ

    View full-size slide

  14. ·ͱΊ
    • Development Assetsͱ͸
    • Development Assetsͷ࢖͍ํ
    • ը૾ϦιʔεʢΞηοτΧλϩάʣҎ֎ͷ༻్
    • ϞοΫΛςετ͚ͩͰͳ͘ϓϨϏϡʔʹ΋࢖͏

    View full-size slide

  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

    View full-size slide

  16. !
    Happy Development

    View full-size slide

  17. Thank you
    @ikesyo / Sho Ikeda

    View full-size slide