This library allows you to view UI components in a catalog-style format.
In most cases, it works by simply adding a few lines of code, as it gathers SwiftUI preview codes at runtime.

-
Install this package into your project.
-
Put the entrypoint view.
import StorybookKit
import SwiftUI
struct ContentView: View {
var body: some View {
Storybook()
}
}
In app executable module
#Preview("Circle") {
Circle()
.fill(.purple)
.frame(width: 100, height: 100)
}
In a dynamic framework module
#Preview("Circle") {
Circle()
.fill(.purple)
.frame(width: 100, height: 100)
}
In a static library module
#Preview("Circle") {
Circle()
.fill(.purple)
.frame(width: 100, height: 100)
}
Important
To display all preview codes in a statically linked binary, you may need to link the binary with the -all_load linker flag. This is because the linker does not load symbols into the target binary if it deems them unnecessary.

Storybook-ios is released under the MIT license.