The markdown parsing is broken/disabled for release notes. Sorry about that, I'm chasing the source of a crash that's been bringing this website down for the last couple of days.
Legacy OS deployment target and Xcode 14
48 weeks ago
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:
```swift
#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!
2 years ago
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…
```swift
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
<img src="https://user-images.githubusercontent.com/1377564/129372268-6c9fe1df-366d-47e9-b0e8-2f092c2c434f.png" alt="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" width="50%" />
Type Erasure not required
2 years ago
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!
2 years ago
Not only can you preview your `UIViewController`s, but now there is support for your `UIView`s as well!
![image](https://user-images.githubusercontent.com/1377564/127796112-cf2de72e-0b32-4b55-ac19-c7388ed18a6d.png)
## API Breaking changes:
- Renamed `PreviewView` to `Preview`
- You can no longer use `.wrapInNavigationController()`, instead make use of the second parameter `Preview(for:navigationControllerStyle:)`
_Before:_
```swift
PreviewView(for: YourViewController())
.wrapInNavigationController()
```
_After:_
```swift
Preview(for: YourViewController(), navigationControllerStyle: .wrap())
```
Rapid Prototyping Begins
2 years ago
🎉🎉🎉
You can now preview your `UIViewControllers` using the SwiftUI preview canvas.