A library for isolated developing UI components and automatically taking snapshots of them.

|
|
#### PlaybookCatalog
The UI that search and select a scenario in a drawer. It's more similar to `Storybook`.
If you have too many scenarios, this may be more efficient than `PlaybookCatalog`.
| Browser | Detail |
| ------- | ------ |
|
|
|
#### How to Save Snapshot Images
To save snapshot images to the photo library from the share button on each UI, `NSPhotoLibraryAddUsageDescription` must be supported. See the [official document](https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW73) for more information.
---
### PlaybookSnapshot
Scenarios can be tested by the instance of types conform to `TestTool` protocol.
`Snapshot` is one of them, which can generate the snapshots of all scenarios with simulate the screen size and safe area of the given devices.
Since Playbook doesn't depend on XCTest, it doesn't necessarily need to be run on Unit-test.
```swift
final class SnapshotTests: XCTestCase {
func testTakeSnapshot() throws {
let directory = ProcessInfo.processInfo.environment["SNAPSHOT_DIR"]!
try Playbook.default.run(
Snapshot(
directory: URL(fileURLWithPath: directory),
clean: true,
format: .png,
devices: [.iPhone15Pro(.portrait)]
)
)
}
}
```
---
### [PlaybookAccessibilitySnapshot](https://github.com/playbook-ui/accessibility-snapshot-ios)
An extension to `Playbook` that uses [AccessibilitySnapshot](https://github.com/cashapp/AccessibilitySnapshot) to produce snapshots with accessibility information such as activation points and labels.
---
### Integration with Third-party Tools
The generated snapshot images can be used for more advanced visual regression testing by using a variety of third party tools.
#### [percy](https://percy.io)
#### [reg-viz/reg-suit](https://github.com/reg-viz/reg-suit)
---
## Requirements
- Swift 5.10
- Xcode 15.4
- iOS 13.0+ (PlaybookUI: iOS 15.0+)
---
## Installation
Playbook features are separated into the following frameworks.
- `Playbook`: Core system of component management.
- `PlaybookSnapshot`: Generates snapshots of all components.
- `PlaybookUI`: Products a browsing UI for components managed by Playbook.
### [Swift Package Manager](https://developer.apple.com/documentation/xcode/adding_package_dependencies_to_your_app)
Select Xcode menu `File > Swift Packages > Add Package Dependency...` and enter repository URL with GUI.
```
Repository: https://github.com/playbook-ui/playbook-ios
```
Note: Currently, SwiftPM doesn't support specifying the OS version for each library, so only `iOS13` is supported.
---
## License
Playbook is released under the [Apache 2.0 License](https://github.com/playbook-ui/playbook-ios/tree/master/LICENSE).