Releases: theoriginalbit/PreviewView
Legacy OS deployment target and Xcode 14
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!
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
Type Erasure not required
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!
Not only can you preview your UIViewController
s, but now there is support for your UIView
s as well!
API Breaking changes:
- Renamed
PreviewView
toPreview
- You can no longer use
.wrapInNavigationController()
, instead make use of the second parameterPreview(for:navigationControllerStyle:)
Before:
PreviewView(for: YourViewController())
.wrapInNavigationController()
After:
Preview(for: YourViewController(), navigationControllerStyle: .wrap())
Rapid Prototyping Begins
🎉🎉🎉
You can now preview your UIViewControllers
using the SwiftUI preview canvas.