Skip to content

Commit d0e1457

Browse files
authored
Update readme (#209)
* Update readme * Update readme and script to upload PreviewGallery
1 parent fc7a10d commit d0e1457

File tree

4 files changed

+23
-9
lines changed

4 files changed

+23
-9
lines changed

.github/workflows/release.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,18 @@ jobs:
1616
run: sudo xcode-select -s '/Applications/Xcode_15.4.app/Contents/Developer'
1717
- name: Build xcframework
1818
run: sh build.sh
19-
- name: Zip xcframework
19+
- name: Zip SnapshottingTests xcframework
2020
run: zip -r SnapshottingTests.xcframework.zip SnapshottingTests.xcframework
21+
- name: Zip PreviewGallery xcframework
22+
run: zip -r PreviewGallery.xcframework.zip PreviewGallery.xcframework
2123
- name: Zip preivews support
2224
run: (cd PreviewsSupport && zip -r PreviewsSupport.xcframework.zip PreviewsSupport.xcframework)
2325
- name: Upload Artifact
2426
uses: softprops/action-gh-release@v1
2527
if: startsWith(github.ref, 'refs/tags/')
2628
with:
2729
files: |
30+
PreviewGallery.xcframework.zip
2831
SnapshottingTests.xcframework.zip
2932
PreviewsSupport/PreviewsSupport.xcframework.zip
3033
body:

Package.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ let package = Package(
1010
// Products define the executables and libraries a package produces, making them visible to other packages.
1111
.library(
1212
name: "PreviewGallery",
13+
type: .static, // Replace this to build dynamic
1314
targets: ["PreviewGallery"]),
1415
// Test library to import in your XCTest target.
1516
// This is the only library that depends on XCTest.framework

README.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# 📸 SnapshotPreviews
22

3-
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FEmergeTools%2FSnapshotPreviews-iOS%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/EmergeTools/SnapshotPreviews-iOS)
4-
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FEmergeTools%2FSnapshotPreviews-iOS%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/EmergeTools/SnapshotPreviews-iOS)
3+
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FEmergeTools%2FSnapshotPreviews%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/EmergeTools/SnapshotPreviews)
4+
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FEmergeTools%2FSnapshotPreviews%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/EmergeTools/SnapshotPreviews)
5+
[![](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fwww.emergetools.com%2Fapi%2Fv2%2Fpublic_new_build%3FexampleId%3Dsnapshotpreviews-ios.PreviewGallery%26platform%3Dios%26badgeOption%3Dversion_and_max_install_size%26buildType%3Drelease&query=$.badgeMetadata&label=PreviewGallery&logo=apple)](https://www.emergetools.com/app/example/ios/snapshotpreviews-ios.PreviewGallery/release?utm_campaign=badge-data)
6+
[![](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fwww.emergetools.com%2Fapi%2Fv2%2Fpublic_new_build%3FexampleId%3Dsnapshotpreviews-ios.SnapshottingTests%26platform%3Dios%26badgeOption%3Dversion_and_max_install_size%26buildType%3Drelease&query=$.badgeMetadata&label=SnapshottingTests&logo=apple)](https://www.emergetools.com/app/example/ios/snapshotpreviews-ios.SnapshottingTests/release?utm_campaign=badge-data)
57

68
An all-in-one snapshot testing solution built on Xcode previews. Automatic browsable gallery of previews, and no-code snapshot generation with XCTest. Supports SwiftUI and UIKit previews using `PreviewProvider` or `#Preview` and works on all Apple platforms (iOS/macOS/watchOS/tvOS/visionOS).
79

@@ -16,7 +18,7 @@ An all-in-one snapshot testing solution built on Xcode previews. Automatic brows
1618
`PreviewGallery` is an interactive UI built on top of snapshot extraction. It turns your Xcode previews into a gallery of components and features you can access from your application, for example in an internal settings screen. **Xcode is not required to view the previews.** You can use it to preview individual components (buttons/rows/icons/etc) or even entire interactive features.
1719

1820
<p align="center">
19-
<img src="https://raw.githubusercontent.com/EmergeTools/SnapshotPreviews-iOS/master/images/image1.png" />
21+
<img src="https://raw.githubusercontent.com/EmergeTools/SnapshotPreviews/master/images/image1.png" />
2022
</p>
2123

2224
The public API of PreviewGallery is a single SwiftUI `View` named `PreviewGallery`. Displaying this view gives you access to the full gallery. For example, you could add a button to open the gallery like this:
@@ -65,7 +67,7 @@ Note that there are no test functions; they are automatically added at runtime b
6567
> [!NOTE]
6668
> When you use Preview macros (`#Preview("Display Name")`) the name of the snapshot uses the file path and the name, for example: "MyModule/MyFile.swift:Display Name"
6769
68-
![Screenshot of Xcode test output](https://raw.githubusercontent.com/EmergeTools/SnapshotPreviews-iOS/master/images/testOutput.png)
70+
![Screenshot of Xcode test output](https://raw.githubusercontent.com/EmergeTools/SnapshotPreviews/master/images/testOutput.png)
6971

7072
The [EmergeTools snapshot testing service](https://docs.emergetools.com/docs/snapshot-testing) generates snapshots and diffs them in the cloud to control for sources of flakiness, store images outside of git, and optimize test performance. `SnapshotTest` is for locally debugging these snapshot tests. You can also use `PreviewTest` to get code coverage of all previews in your unit test without generating PNGs. This will validate that previews do not crash (such as a missing @EnvironmentObject) but runs faster because it does not render the views to images.
7173

@@ -101,10 +103,10 @@ See the demo app for a full example.
101103

102104
# Installation
103105

104-
Add the package dependency to your Xcode project using the URL of this repository (https://github.com/EmergeTools/SnapshotPreviews-iOS).
106+
Add the package dependency to your Xcode project using the URL of this repository (https://github.com/EmergeTools/SnapshotPreviews).
105107

106108
<p align="center">
107-
<img src="https://raw.githubusercontent.com/EmergeTools/SnapshotPreviews-iOS/master/images/image2.png" />
109+
<img src="https://raw.githubusercontent.com/EmergeTools/SnapshotPreviews/master/images/image2.png" />
108110
</p>
109111

110112
Link your app to `PreviewGallery` and (optionally) to `SnapshotPreferences` to customize the behavior of snapshot generation.
@@ -150,7 +152,7 @@ Check `ProcessInfo.isRunningPeviews` to disable behavior you don’t want in pre
150152
> [!TIP]
151153
> Using PreviewVariants greatly simplifies snapshot testing, by ensuring a consistent set of variants and that every view is provided a name.
152154
153-
Using multiple variants of the same view can ensure test coverage of all the ways users interact with your UI. Most are provided by SwiftUI, eg: `.dynamicTypeSize(.xxxLarge)`. There is one built into the package: `.emergeAccessibility(true)`. This function adds a visualization of voice over elements to your snapshot. You can automatically add variants using the [`PreviewVariants` View](https://github.com/EmergeTools/SnapshotPreviews-iOS/blob/main/DemoApp/DemoApp/TestViews/PreviewVariants.swift) that is demonstrated in the example app. It adds RTL, landscape, accessibility, dark mode and large text variants. You can use it like this:
155+
Using multiple variants of the same view can ensure test coverage of all the ways users interact with your UI. Most are provided by SwiftUI, eg: `.dynamicTypeSize(.xxxLarge)`. There is one built into the package: `.emergeAccessibility(true)`. This function adds a visualization of voice over elements to your snapshot. You can automatically add variants using the [`PreviewVariants` View](https://github.com/EmergeTools/SnapshotPreviews/blob/main/DemoApp/DemoApp/TestViews/PreviewVariants.swift) that is demonstrated in the example app. It adds RTL, landscape, accessibility, dark mode and large text variants. You can use it like this:
154156

155157
```swift
156158
struct MyView_Previews: PreviewProvider {
@@ -172,7 +174,7 @@ struct MyView_Previews: PreviewProvider {
172174

173175
# Star History
174176

175-
[![Star History Chart](https://api.star-history.com/svg?repos=EmergeTools/SnapshotPreviews-iOS&type=Date)](https://star-history.com/#EmergeTools/SnapshotPreviews-iOS&Date)
177+
[![Star History Chart](https://api.star-history.com/svg?repos=EmergeTools/SnapshotPreviews&type=Date)](https://star-history.com/#EmergeTools/SnapshotPreviews&Date)
176178

177179
# Related Reading
178180
- [How to use VariadicView, SwiftUI's Private View API](https://www.emergetools.com/blog/posts/how-to-use-variadic-view): VariadicView is a core part of how multiple images are rendered for one PreviewProvider.

build.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,18 @@ build_framework() {
4545
# Update the Package.swift to build the library as dynamic instead of static
4646
sed -i '' '/Replace this/ s/.*/type: .dynamic,/' Package.swift
4747

48+
# Build SnapshottingTests
4849
build_framework "iphonesimulator" "generic/platform=iOS Simulator" "SnapshottingTests"
4950
build_framework "iphoneos" "generic/platform=iOS" "SnapshottingTests"
5051

52+
# Build PreviewGallery
53+
build_framework "iphonesimulator" "generic/platform=iOS Simulator" "PreviewGallery"
54+
build_framework "iphoneos" "generic/platform=iOS" "PreviewGallery"
55+
5156
echo "Builds completed successfully."
5257

5358
rm -rf "SnapshottingTests.xcframework"
5459
xcodebuild -create-xcframework -framework SnapshottingTests-iphonesimulator.xcarchive/Products/Library/Frameworks/SnapshottingTests.framework -framework SnapshottingTests-iphoneos.xcarchive/Products/Library/Frameworks/SnapshottingTests.framework -output SnapshottingTests.xcframework
60+
61+
rm -rf "PreviewGallery.xcframework"
62+
xcodebuild -create-xcframework -framework PreviewGallery-iphonesimulator.xcarchive/Products/Library/Frameworks/PreviewGallery.framework -framework PreviewGallery-iphoneos.xcarchive/Products/Library/Frameworks/PreviewGallery.framework -output PreviewGallery.xcframework

0 commit comments

Comments
 (0)