AltPreviewProvider

@available(iOS 13.0.0, *)
public protocol AltPreviewProvider : PreviewProvider

A type that produces AltSwiftUI view previews in Xcode.

Xcode statically discovers types that conform to the AltPreviewProvider protocol in your app, and generates previews for each provider it discovers.

Note: In case you can’t get the preview window to show, make sure Editor -> Canvas is enabled. Additionally, you can access another file whose canvas is properly showing, and then pin it so that it is visible in all files.

  • Generates a preview of one view.

    The following code shows how to create a preview provider for previewing a MyText view:

    #if DEBUG && canImport(SwiftUI)
    
    import protocol SwiftUI.PreviewProvider
    import protocol RakutenTravelCore.View
    
    struct MyTextPreview : AltPreviewProvider, PreviewProvider {
        static var previewView: View {
            MyText()
        }
    }
    
    #endif
    

    Declaration

    Swift

    static var previewView: View { get }

Public Types

  • previews Extension method

    Declaration

    Swift

    static var previews: some SwiftUI.View { get }