diff --git a/src/assets/json/en/ios/wwdc/ios-wwdc-listnota11y.json b/src/assets/json/en/ios/wwdc/ios-wwdc-listnota11y.json index 860f0e48a..f72d15e87 100644 --- a/src/assets/json/en/ios/wwdc/ios-wwdc-listnota11y.json +++ b/src/assets/json/en/ios/wwdc/ios-wwdc-listnota11y.json @@ -10,6 +10,17 @@ "raccourcis": "", "profils": ["All","Accessibility","Dark Mode","Debugging","DocC","Formatting","Instruments","Keyboard","Keynote","Localization","Optimization","Platforms State...","Regex","Shortcuts","Swift","Swift Playgrounds","SwiftUI","What's new in...","Xcode"] }, + { + "themes": "WWDC 2023", + "title": "Build programmatic UI with Xcode Previews", + "type": [], + "tests": [], + "verifier": [], + "resultat": [], + "exception": "", + "raccourcis": "2023/2310252", + "profils": ["All","SwiftUI","Xcode"] + }, { "themes": "WWDC 2023", "title": "Expand on Swift macros", diff --git a/src/en/mobile/images/iOSdev/wwdc23-10252_1.png b/src/en/mobile/images/iOSdev/wwdc23-10252_1.png new file mode 100644 index 000000000..fe26481ba Binary files /dev/null and b/src/en/mobile/images/iOSdev/wwdc23-10252_1.png differ diff --git a/src/en/mobile/images/iOSdev/wwdc23-10252_10.png b/src/en/mobile/images/iOSdev/wwdc23-10252_10.png new file mode 100644 index 000000000..11a778f9a Binary files /dev/null and b/src/en/mobile/images/iOSdev/wwdc23-10252_10.png differ diff --git a/src/en/mobile/images/iOSdev/wwdc23-10252_11.png b/src/en/mobile/images/iOSdev/wwdc23-10252_11.png new file mode 100644 index 000000000..da181dc56 Binary files /dev/null and b/src/en/mobile/images/iOSdev/wwdc23-10252_11.png differ diff --git a/src/en/mobile/images/iOSdev/wwdc23-10252_12.png b/src/en/mobile/images/iOSdev/wwdc23-10252_12.png new file mode 100644 index 000000000..662e66c17 Binary files /dev/null and b/src/en/mobile/images/iOSdev/wwdc23-10252_12.png differ diff --git a/src/en/mobile/images/iOSdev/wwdc23-10252_13.png b/src/en/mobile/images/iOSdev/wwdc23-10252_13.png new file mode 100644 index 000000000..f04f32ff7 Binary files /dev/null and b/src/en/mobile/images/iOSdev/wwdc23-10252_13.png differ diff --git a/src/en/mobile/images/iOSdev/wwdc23-10252_14.png b/src/en/mobile/images/iOSdev/wwdc23-10252_14.png new file mode 100644 index 000000000..1bf00ed77 Binary files /dev/null and b/src/en/mobile/images/iOSdev/wwdc23-10252_14.png differ diff --git a/src/en/mobile/images/iOSdev/wwdc23-10252_15.png b/src/en/mobile/images/iOSdev/wwdc23-10252_15.png new file mode 100644 index 000000000..14fe5709b Binary files /dev/null and b/src/en/mobile/images/iOSdev/wwdc23-10252_15.png differ diff --git a/src/en/mobile/images/iOSdev/wwdc23-10252_16.png b/src/en/mobile/images/iOSdev/wwdc23-10252_16.png new file mode 100644 index 000000000..9eb9a28f8 Binary files /dev/null and b/src/en/mobile/images/iOSdev/wwdc23-10252_16.png differ diff --git a/src/en/mobile/images/iOSdev/wwdc23-10252_17.png b/src/en/mobile/images/iOSdev/wwdc23-10252_17.png new file mode 100644 index 000000000..05b342462 Binary files /dev/null and b/src/en/mobile/images/iOSdev/wwdc23-10252_17.png differ diff --git a/src/en/mobile/images/iOSdev/wwdc23-10252_18.png b/src/en/mobile/images/iOSdev/wwdc23-10252_18.png new file mode 100644 index 000000000..ca91efab2 Binary files /dev/null and b/src/en/mobile/images/iOSdev/wwdc23-10252_18.png differ diff --git a/src/en/mobile/images/iOSdev/wwdc23-10252_19.png b/src/en/mobile/images/iOSdev/wwdc23-10252_19.png new file mode 100644 index 000000000..5eeb06092 Binary files /dev/null and b/src/en/mobile/images/iOSdev/wwdc23-10252_19.png differ diff --git a/src/en/mobile/images/iOSdev/wwdc23-10252_2.png b/src/en/mobile/images/iOSdev/wwdc23-10252_2.png new file mode 100644 index 000000000..251fd4963 Binary files /dev/null and b/src/en/mobile/images/iOSdev/wwdc23-10252_2.png differ diff --git a/src/en/mobile/images/iOSdev/wwdc23-10252_20.png b/src/en/mobile/images/iOSdev/wwdc23-10252_20.png new file mode 100644 index 000000000..a968f1cff Binary files /dev/null and b/src/en/mobile/images/iOSdev/wwdc23-10252_20.png differ diff --git a/src/en/mobile/images/iOSdev/wwdc23-10252_21.png b/src/en/mobile/images/iOSdev/wwdc23-10252_21.png new file mode 100644 index 000000000..06855eb37 Binary files /dev/null and b/src/en/mobile/images/iOSdev/wwdc23-10252_21.png differ diff --git a/src/en/mobile/images/iOSdev/wwdc23-10252_22.png b/src/en/mobile/images/iOSdev/wwdc23-10252_22.png new file mode 100644 index 000000000..740331ea0 Binary files /dev/null and b/src/en/mobile/images/iOSdev/wwdc23-10252_22.png differ diff --git a/src/en/mobile/images/iOSdev/wwdc23-10252_23.png b/src/en/mobile/images/iOSdev/wwdc23-10252_23.png new file mode 100644 index 000000000..2fedd2053 Binary files /dev/null and b/src/en/mobile/images/iOSdev/wwdc23-10252_23.png differ diff --git a/src/en/mobile/images/iOSdev/wwdc23-10252_24.png b/src/en/mobile/images/iOSdev/wwdc23-10252_24.png new file mode 100644 index 000000000..9c8f80b97 Binary files /dev/null and b/src/en/mobile/images/iOSdev/wwdc23-10252_24.png differ diff --git a/src/en/mobile/images/iOSdev/wwdc23-10252_25.png b/src/en/mobile/images/iOSdev/wwdc23-10252_25.png new file mode 100644 index 000000000..18e22d7ad Binary files /dev/null and b/src/en/mobile/images/iOSdev/wwdc23-10252_25.png differ diff --git a/src/en/mobile/images/iOSdev/wwdc23-10252_3.png b/src/en/mobile/images/iOSdev/wwdc23-10252_3.png new file mode 100644 index 000000000..0f44ea26d Binary files /dev/null and b/src/en/mobile/images/iOSdev/wwdc23-10252_3.png differ diff --git a/src/en/mobile/images/iOSdev/wwdc23-10252_4.png b/src/en/mobile/images/iOSdev/wwdc23-10252_4.png new file mode 100644 index 000000000..4b1b8415d Binary files /dev/null and b/src/en/mobile/images/iOSdev/wwdc23-10252_4.png differ diff --git a/src/en/mobile/images/iOSdev/wwdc23-10252_5.png b/src/en/mobile/images/iOSdev/wwdc23-10252_5.png new file mode 100644 index 000000000..c67b7ce10 Binary files /dev/null and b/src/en/mobile/images/iOSdev/wwdc23-10252_5.png differ diff --git a/src/en/mobile/images/iOSdev/wwdc23-10252_6.png b/src/en/mobile/images/iOSdev/wwdc23-10252_6.png new file mode 100644 index 000000000..de3bc49e0 Binary files /dev/null and b/src/en/mobile/images/iOSdev/wwdc23-10252_6.png differ diff --git a/src/en/mobile/images/iOSdev/wwdc23-10252_7.png b/src/en/mobile/images/iOSdev/wwdc23-10252_7.png new file mode 100644 index 000000000..8f3cc75e8 Binary files /dev/null and b/src/en/mobile/images/iOSdev/wwdc23-10252_7.png differ diff --git a/src/en/mobile/images/iOSdev/wwdc23-10252_8.png b/src/en/mobile/images/iOSdev/wwdc23-10252_8.png new file mode 100644 index 000000000..21a68afad Binary files /dev/null and b/src/en/mobile/images/iOSdev/wwdc23-10252_8.png differ diff --git a/src/en/mobile/images/iOSdev/wwdc23-10252_9.png b/src/en/mobile/images/iOSdev/wwdc23-10252_9.png new file mode 100644 index 000000000..25d17500b Binary files /dev/null and b/src/en/mobile/images/iOSdev/wwdc23-10252_9.png differ diff --git a/src/en/mobile/images/iOSdev/wwdc23-10252_Poster.png b/src/en/mobile/images/iOSdev/wwdc23-10252_Poster.png new file mode 100644 index 000000000..554a63b65 Binary files /dev/null and b/src/en/mobile/images/iOSdev/wwdc23-10252_Poster.png differ diff --git a/src/en/mobile/ios/wwdc/nota11y/2023/2310252.md b/src/en/mobile/ios/wwdc/nota11y/2023/2310252.md new file mode 100644 index 000000000..9a7d6b7d7 --- /dev/null +++ b/src/en/mobile/ios/wwdc/nota11y/2023/2310252.md @@ -0,0 +1,326 @@ +--- +title : "Build programmatic UI with Xcode Previews" +abstract: "Learn how you can use the #Preview macro on Xcode 15 to quickly iterate on your UI code written in SwiftUI, UIKit, or AppKit." + +displayToc: true +--- + +# WWDC 2023: Build programmatic UI with Xcode Previews +Find hereafter a detailed summary of a video that belongs to a [taxonomy of some WWDC footages](../../). + +The original videos is available on the **Apple official website** ([session 10252](https://developer.apple.com/videos/play/wwdc2023/10252/)). + +![](../../../../../images/iOSdev/wwdc23-10252_Poster.png) + +"Learn how you can use the **#Preview macro on `Xcode 15`** to quickly iterate on your UI code written in SwiftUI, UIKit, or AppKit. Explore a collage of unique workflows for **interacting with views right in the canvas**, find out how to **view multiple variations of UI simultaneously**, and discover how you can **travel through your widget's timeline** in seconds to test the transitions between entries. We'll also show you how to add previews to libraries, provide sample assets, and preview your views in your physical devices to leverage their capabilities and existing data." +
Hereafter, the underlined elements lead directly to the playback of the WWDC video at the appropriate moment. +
+ +## [Overview](https://developer.apple.com/videos/play/wwdc2023/10252/?time=87) +**Previews** are handled by the **#Preview macro** to return views that are automatically managed by the system when changes are added in the `Swift` code. +![](../../../../../images/iOSdev/wwdc23-10252_1.png) + +Using the previews leads towards [major pros](https://developer.apple.com/videos/play/wwdc2023/10252/?time=171) that streamline the code programing. + +![](../../../../../images/iOSdev/wwdc23-10252_2.png) +
+ +## [Previews contents](https://developer.apple.com/videos/play/wwdc2023/10252/?time=228) +Two different types of elements can be previewed: the **views** and the **widgets**. +### Views +![](../../../../../images/iOSdev/wwdc23-10252_6.png) + + +
+
+ +🎬 + +Regarded as [scenes](https://developer.apple.com/videos/play/wwdc2023/10252/?time=312), the previews may display nested views with added modifiers and [dedicated configuration traits](https://developer.apple.com/videos/play/wwdc2023/10252/?time=331) if need be. + +![](../../../../../images/iOSdev/wwdc23-10252_7.png) + +
+ +
+ +🎬 + +According to the use case, a view controller might need to be incorporated for getting the sought preview. + +![](../../../../../images/iOSdev/wwdc23-10252_8.png) +
+
+
+
+ +### [Widgets](https://developer.apple.com/videos/play/wwdc2023/10252/?time=700) +![](../../../../../images/iOSdev/wwdc23-10252_5.png) + + +
+
+ +🎬 + +Regarding the **timeline provider**, the canvas supplies snapshots so as to take a look at the [final rendering](https://developer.apple.com/videos/play/wwdc2023/10252/?time=757). +![](../../../../../images/iOSdev/wwdc23-10252_18.png) + +A **specific timeline** for particular entries may also be implemented for [assessing](https://developer.apple.com/videos/play/wwdc2023/10252/?time=793) special use cases that can be fixed in the canvas thanks to the [pin button](https://developer.apple.com/videos/play/wwdc2023/10252/?time=826) when going to other files. +![](../../../../../images/iOSdev/wwdc23-10252_19.png) + +
+ +
+ +🎬 + +This type of widget requires two kind of sets: the **live activity attributes** and their possible **states**. +![](../../../../../images/iOSdev/wwdc23-10252_4.png) +
+
+
+
+ +## [Xcode features](https://developer.apple.com/videos/play/wwdc2023/10252/?time=379) +### [Canvas](https://developer.apple.com/videos/play/wwdc2023/10252/?time=401) +Before dealing with the previews, it's important to be sure the **canvas mode** is enabled. +![](../../../../../images/iOSdev/wwdc23-10252_9.png) +When enabled, the canvas is displayed and concomittandly updated as soon as the [first preview](https://developer.apple.com/videos/play/wwdc2023/10252/?time=424) is implemented. +
+ +### [Mode of previews](https://developer.apple.com/videos/play/wwdc2023/10252/?time=437) + + +
+
+ +🎬 + +The first mode is the **live mode** that gives rise to interactivity, animations and asynchronous actions through the canvas. + +![](../../../../../images/iOSdev/wwdc23-10252_10.png) + +
+ +
+ +🎬 + +The **static mode** renders a snapshot of the view and enables interactions with the components while changing the code thereof. + +![](../../../../../images/iOSdev/wwdc23-10252_11.png) +
+ +
+ +🎬 + +The **variants mode** displays the settings for the features provided in the `preview environment` explained in the next tab. + +![](../../../../../images/iOSdev/wwdc23-10252_13.png) + +All the **dynamic type sizes** can be rendered while selecting one of them and enabling to slide towards each other. + +![](../../../../../images/iOSdev/wwdc23-10252_14.png) +
+ +
+ +🎬 + +The previews may also be enriched by the `Color Scheme`, the `Orientation` and the `Dynamic Type` feature through the **Device Settings popover** located in the canvas. + +![](../../../../../images/iOSdev/wwdc23-10252_12.png) +
+
+
+
+ +### Tips & tricks +1. Fix the position of `SwiftUI` elements according to their [dynamic type sizes](https://developer.apple.com/videos/play/wwdc2023/10252/?time=552) in two steps. + + +
+
+ +🎬 + +Use a `Form` instead of a `VStack` for grouping the controls inside sections. + +![](../../../../../images/iOSdev/wwdc23-10252_15.png) + +
+ +
+ +🎬 + +Add a header to the created sections. +![](../../../../../images/iOSdev/wwdc23-10252_16.png) +
+
+
+
+ +2. Add an [image filter](https://developer.apple.com/videos/play/wwdc2023/10252/?time=638) inside a view controller. +![](../../../../../images/iOSdev/wwdc23-10252_17.png) + +## [Previews in a project](https://developer.apple.com/videos/play/wwdc2023/10252/?time=959) +### [Previewing in libraries](https://developer.apple.com/videos/play/wwdc2023/10252/?time=975) +Previews rely on [three source elements](https://developer.apple.com/videos/play/wwdc2023/10252/?time=1020) to unravel the **appropriate executable** to be used. +![](../../../../../images/iOSdev/wwdc23-10252_20.png) +Should [no app exist](https://developer.apple.com/videos/play/wwdc2023/10252/?time=1086), the system creates it under a **XCPreviewAgent** for loading the library. + +Based on the suggested [two ways](https://developer.apple.com/videos/play/wwdc2023/10252/?time=1112) for **improving the libraries previews**, the crucial steps to create a [dedicated app](https://developer.apple.com/videos/play/wwdc2023/10252/?time=1152) for previews are highlighted and detailed hereafter. + + + +
+
+ +🎬 +![](../../../../../images/iOSdev/wwdc23-10252_21.png) + +
+ +
+ +🎬 +![](../../../../../images/iOSdev/wwdc23-10252_22.png) +
+ +
+ +🎬 +![](../../../../../images/iOSdev/wwdc23-10252_23.png) +
+
+
+
+ +### [Providing sample assets](https://developer.apple.com/videos/play/wwdc2023/10252/?time=1226) +The **[Development Assets](https://developer.apple.com/videos/play/wwdc2023/10252/?time=1269)** feature might be of a great help while automatically removing everything inside specific paths when submitting to the `App` `Store`. +![](../../../../../images/iOSdev/wwdc23-10252_3.png) +
+ +### [Leveraging devices](https://developer.apple.com/videos/play/wwdc2023/10252/?time=1341) +Previews can be performed through the **preview device picker** located in the canvas: +1. In the **Automatic mode**, +2. Thanks to a specific **device feature** found out in the middle section, +3. With a loaded **simulator device** pointed out with the `More` submenu. +![](../../../../../images/iOSdev/wwdc23-10252_24.png) + +Besides the simulators, previews may also be displayed on [real devices](https://developer.apple.com/videos/play/wwdc2023/10252/?time=1448) including all the features `Xcode` provides for previewing. + +![](../../../../../images/iOSdev/wwdc23-10252_25.png) +
diff --git a/src/en/mobile/ios/wwdc/nota11y/index.md b/src/en/mobile/ios/wwdc/nota11y/index.md index cf05423f4..a5d3d9c5c 100644 --- a/src/en/mobile/ios/wwdc/nota11y/index.md +++ b/src/en/mobile/ios/wwdc/nota11y/index.md @@ -24,6 +24,7 @@ The videos that may be of interest to **designers** are highlighted with a **ded