Skip to content

Releases: theoriginalbit/PreviewView

Legacy OS deployment target and Xcode 14

22 May 04:23
Compare
Choose a tag to compare

If your project is targeting iOS versions earlier than iOS 13 you may have run into the following error:

Compiling failed: '__designTimeString(_:fallback:)' is only available in iOS 13.0 or newer

You may see variations on the above with __designTimeInteger, __designTimeBoolean, or __designTimeFloat.

This update introduces a new PreviewViewLegacyOSCompileFix target to fix #3. Simply import it and you're back up and running.

Example for supporting iOS versions earlier than iOS 13:

#if canImport(SwiftUI) && DEBUG
import PreviewView
import PreviewViewLegacyOSCompileFix
import SwiftUI

@available(iOS 13, *)
struct YourNavigationController_Previews: PreviewProvider {
    static var previews: some View {
        ViewControllerPreview(YourNavigationController())
            .edgesIgnoringSafeArea(.all)
    }
}
#endif

Declarative Previews!

13 Aug 14:37
Compare
Choose a tag to compare

A rewrite from the ground up, your UIKit previews are now defined from a SwiftUI-inspired DSL.

Replicating a complex in-app design has never been easier, whether the screen you're previewing should show tab bars, large navigation bars, back buttons, toolbars, or all of them at once!

Simply declare how the preview should look…

struct YourViewController_Previews: PreviewProvider {
    static var previews: some View {
        TabBarControllerPreview(selectedIndex: 1) {
            PreviewBlankTabItem(title: "First", symbolNamed: "capsule")
            NavigationControllerPreview(barStyle: .largeTitle, showsToolbar: true) {
                YourViewController()
                YourViewController()
            }
            PreviewBlankTabItem(title: "Third", symbolNamed: "diamond")
        }
        .ignoresSafeArea(.all)
    }
}

…and let PreviewView do the rest

A screenshot of a SwiftUI preview canvas showing a large titled navigation bar with a back arrow, a view controller with a list of items, a toolbar, and a tab bar with 3 tabs

Type Erasure not required

07 Aug 05:20
Compare
Choose a tag to compare

Through the powers of @ViewBuilder I've finally gone ahead and removed the erasure via AnyView. It should have always been this way, so now it is.

Preview all the Things!

02 Aug 02:25
Compare
Choose a tag to compare

Not only can you preview your UIViewControllers, but now there is support for your UIViews as well!

image

API Breaking changes:

  • Renamed PreviewView to Preview
  • You can no longer use .wrapInNavigationController(), instead make use of the second parameter Preview(for:navigationControllerStyle:)

Before:

PreviewView(for: YourViewController())
    .wrapInNavigationController()

After:

Preview(for: YourViewController(), navigationControllerStyle: .wrap())

Rapid Prototyping Begins

02 Aug 02:19
Compare
Choose a tag to compare

🎉🎉🎉

You can now preview your UIViewControllers using the SwiftUI preview canvas.