Contents

eure/swift-storybook

This library allows you to view UI components in a catalog-style format.

Setup

  1. Install this package into your project.
  1. Put the entrypoint view.
import StorybookKit
import SwiftUI

struct ContentView: View {
  var body: some View {
    Storybook()
  }
}

Example

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.

<img width="150px" src="https://github.com/user-attachments/assets/f849a5a1-c0df-4551-a9a8-c5a0367fe459" alt="list of modules">

Maintainers

License

Storybook-ios is released under the MIT license.

Package Metadata

Repository: eure/swift-storybook

Default branch: main

README: README.md