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

Swift愛好会WWDC要約会 Build programmatic UI with Xcod...

Aikawa
June 22, 2023

Swift愛好会WWDC要約会 Build programmatic UI with Xcode Previews

Aikawa

June 22, 2023
Tweet

More Decks by Aikawa

Other Decks in Technology

Transcript

  1. Build programmatic UI 
 with Xcode Previews Xcode Previews ͷվળ఺΍

    Tips Λཁ໿ͯ͠঺հ͠·͢ SwiftѪ޷ձεϐϯΦϑ WWDC23ηογϣϯཁ໿ձ
  2. ঺հ͢Δ͜ͱ • Xcode Previews ͱ͸ʁ • Xcode Previews ͷվળ఺ ‣

    `#Preview` macro ͷొ৔ ‣ Widgets ͷ Preview ͕Մೳʹ ‣ Previews Λදࣔ͢ΔσόΠε͕બ୒Մೳʹ • Xcode Previews Λར༻͢Δࡍͷ Tips ‣ Library targets Ͱ Preview ͢Δํ๏ ‣ Previews Ͱ assets ͳͲΛར༻͢Δํ๏ ‣ Previews ͰσόΠεݻ༗ͷػೳΛར༻͢Δํ๏
  3. Xcode Previews Λར༻͢Δࡍͷ Tips • Library targets Ͱ Preview ͢Δํ๏

    • Previews Ͱ data ΍ assets Λར༻͢Δํ๏ • ࣮ػͰ͔͠Ͱ͖ͳ͍͜ͱΛ Previews Ͱࢼ͢ํ๏
  4. Library targets Ͱ Preview ͢Δ • Library targets ‣ Frameworks,

    Packages, Dynamic libraries • Library targets Λར༻͢Δ໨తྫ ‣ ϚϧνϞδϡʔϧԽ ‣ ϥΠϒϥϦͷ։ൃ • Library targets Ͱ Preview ͢Δʹ͸Ͳ͏͢Ε͹ʁ
  5. Xcode Previews ͷ࢓૊Έ • ௨ৗɺPreviews Λىಈͯ͠ϨϯμϦϯά͢ΔͨΊʹ͸ App ΍ 
 Widget

    ͳͲͷExecutable ͕ඞཁ • Previews ͸ Executable Λݟ͚ͭΔͨΊʹҎԼͷ 3 ͭΛ࢖༻͢Δ ‣ Edited source fi les - ࡞ۀ͍ͯ͠ΔιʔεϑΝΠϧ ‣ Target dependencies - ࡞ۀ͍ͯ͠ΔϑΝΠϧΛؚΉ target ͓Αͼ target ͷશͯͷґଘؔ܎ ‣ Selected scheme - બ୒͞Ε͍ͯΔ scheme ͱ Target dependencies Λ૊Έ߹ΘͤΔ
  6. XCPreviewAgent ͕ࣗಈͰ࡞੒͞ΕΔ https://developer.apple.com/wwdc23/10252 • ࣗಈͰ XCPreviewAgent 
 ͱ͍͏ΞϓϦΛ࡞Γɺ 
 library

    ΛಡΈࠐ΋͏ͱ͢Δ • Previews ͰΫϥογϡͨ࣌͠ 
 ͳͲɺXCPreviewAgent ͱ͍͏ 
 ϓϩηεΛ஌͓ͬͯ͘ͱศར • ໰୊͕ى͖ͨݪҼΛߜΕΔ͔΋
  7. Library targets Ͱ Previews ΛΑΓշదʹ 
 ಈ࡞ͤ͞ΔͨΊͷํ๏ • Previews ͷ࢓૊ΈΛར༻͢Ε͹ɺ͍͔ͭ͘ͷํ๏Ͱ

    Previews Λ 
 շదʹಈ࡞ͤ͞ΒΕΔ • ঺հ͞Ε͍ͯͨ 2 ͭͷํ๏ ‣ ίʔυΛ library targets ʹϞδϡʔϧԽͯ͠খ͞ͳ scheme Λ࡞Δ ‣ Preview ઐ༻ͷখ͞ͳΞϓϦ (executable) Λ࡞੒͢Δ - ࡞੒ํ๏ʹ͍ͭͯ͸ηογϣϯͷதͰղઆ͞Ε͍ͯ·͢
  8. Development Assets Ͱ App Store ༻ͷΞϓϦ 
 ͔ΒPreviews ༻ assets

    ͳͲΛࣗಈͰ࡟আ͢Δ https://developer.apple.com/wwdc23/10252
  9. Ҿ༻ɾࢀߟ • Build programmatic UI with Xcode Previews ‣ https://developer.apple.com/wwdc23/10252

    • Xcode 15 Beta Release Notes ‣ https://developer.apple.com/documentation/xcode-release-notes/ xcode-15-release-notes#DeviceDiscoveryUI