Storybook

2.6.0

Automatically collecting #Preview and displaying them in your app.
eure/swift-storybook

What's New

2.6.0

2025-04-11T06:04:45Z

What's Changed

Full Changelog: 2.5.0...2.6.0

Storybook for iOS

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.

storybook previewing

Setup

  1. Install this package into your project.

  2. 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.

list of modules

License

Storybook-ios is released under the MIT license.

Description

  • Swift Tools 6.0.0
View More Packages from this Author

Dependencies

Last updated: Tue May 20 2025 12:21:02 GMT-0900 (Hawaii-Aleutian Daylight Time)