WWDC19
=================
Session materials: https://developer.apple.com/videos/play/wwdc2019/233/
- Xcode builds a preview of the current view separately and injects the view with dynamic replacement to show in the preview mode
# if DEBUG
public enum SomePreviews: PreviewProvider {
public static var previews: some View {
Group {
SomeView()
.device() // Different devices to be shown in the preview
.previewLayout(.sizeThatFits) // Just shows the specific view with the intrinsic size it gets,
SomeView()
.environment(|.sizeCategory, .extraLarge) // To simulate dynamic text sizes on the preview
.previewDisplayName() // to show the selected preview option in the preview mode
}
}
}
#endif
- Wrap previewable views into forEach to simulate different cases of an iterable like dynamic font types
- Target settings -> General -> Development Assets
-
Parse a given JSON with a simple decoder to have a variety of data to be able to check different cases on the preview UI
-
Pinning a preview will make it sticky across other views to make it visible everywhere
- A separate previews file
// Implement following two protocols to make the vc previewable
PreviewProvider
static var previews
UIViewControllerRepresentable
func makeUIViewController() {
// load from storyboard or instantiate
}
func updateUIViewController() {}
- Make your apps scene aware