Skip to content

Automatically collecting #Preview and displaying them in your app.

License

Notifications You must be signed in to change notification settings

eure/swift-storybook

Repository files navigation

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.

About

Automatically collecting #Preview and displaying them in your app.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •