Add snapshot package

This commit is contained in:
Noah Martin 2023-12-26 07:41:50 -08:00
parent 76ced9f8e3
commit 6deeeb384b
11 changed files with 93 additions and 16 deletions

View file

@ -103,6 +103,7 @@
54F15E5429D59D250054690B /* PulseExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 54F15E5329D59D250054690B /* PulseExample.swift */; };
54F15E5629D5A0D70054690B /* GlowExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 54F15E5529D5A0D70054690B /* GlowExample.swift */; };
B7A5DA8D2B0E853A0035FC0A /* Pow in Frameworks */ = {isa = PBXBuildFile; productRef = B7A5DA8C2B0E853A0035FC0A /* Pow */; };
FA13B8ED2B3BAF5600F58836 /* SnapshotPreferences in Frameworks */ = {isa = PBXBuildFile; productRef = FA13B8EC2B3BAF5600F58836 /* SnapshotPreferences */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
@ -212,6 +213,7 @@
buildActionMask = 2147483647;
files = (
B7A5DA8D2B0E853A0035FC0A /* Pow in Frameworks */,
FA13B8ED2B3BAF5600F58836 /* SnapshotPreferences in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -420,6 +422,7 @@
name = "Pow Example";
packageProductDependencies = (
B7A5DA8C2B0E853A0035FC0A /* Pow */,
FA13B8EC2B3BAF5600F58836 /* SnapshotPreferences */,
);
productName = "Pow Example";
productReference = 546A2986292A31BB00A80DE2 /* Pow Example.app */;
@ -450,6 +453,7 @@
);
mainGroup = 546A297D292A31BB00A80DE2;
packageReferences = (
FA13B8EB2B3BAF5600F58836 /* XCRemoteSwiftPackageReference "SnapshotPreviews-iOS" */,
);
productRefGroup = 546A2987292A31BB00A80DE2 /* Products */;
projectDirPath = "";
@ -777,11 +781,27 @@
};
/* End XCConfigurationList section */
/* Begin XCRemoteSwiftPackageReference section */
FA13B8EB2B3BAF5600F58836 /* XCRemoteSwiftPackageReference "SnapshotPreviews-iOS" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/EmergeTools/SnapshotPreviews-iOS";
requirement = {
kind = exactVersion;
version = 0.7.6;
};
};
/* End XCRemoteSwiftPackageReference section */
/* Begin XCSwiftPackageProductDependency section */
B7A5DA8C2B0E853A0035FC0A /* Pow */ = {
isa = XCSwiftPackageProductDependency;
productName = Pow;
};
FA13B8EC2B3BAF5600F58836 /* SnapshotPreferences */ = {
isa = XCSwiftPackageProductDependency;
package = FA13B8EB2B3BAF5600F58836 /* XCRemoteSwiftPackageReference "SnapshotPreviews-iOS" */;
productName = SnapshotPreferences;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = 546A297E292A31BB00A80DE2 /* Project object */;

View file

@ -1,5 +1,6 @@
import Pow
import SwiftUI
import SnapshotPreferences
struct CheckoutExample: View, Example {
enum PaymentError: Error {
@ -271,5 +272,6 @@ struct CheckoutExample_Previews: PreviewProvider {
CheckoutExample()
.toolbar(.visible, for: .navigationBar)
}
.emergeSnapshotPrecision(0.99)
}
}

View file

@ -3,6 +3,10 @@ fastlane_require 'git'
default_platform(:ios)
def build_for_config(config)
package_file = "../Package.swift"
`sed -i '' 's/let enablePreviews = .*/let enablePreviews = #{config == "Debug" ? "true" : "false"}/' "#{package_file}"`
g = Git.open('.')
build_app(
project: "./Example/Pow Example.xcodeproj",

View file

@ -3,6 +3,8 @@
import PackageDescription
let enablePreviews = false
let package = Package(
name: "Pow",
platforms: [
@ -19,13 +21,15 @@ let package = Package(
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
.package(url: "https://github.com/EmergeTools/SnapshotPreviews-iOS", exact: "0.7.6")
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "Pow",
dependencies: []),
dependencies: enablePreviews ? [.product(name: "SnapshotPreferences", package: "SnapshotPreviews-iOS", condition: .when(platforms: [.iOS]))] : [],
swiftSettings: enablePreviews ? [.define("EMG_PREVIEWS")] : nil),
.testTarget(
name: "PowTests",
dependencies: ["Pow"]),

View file

@ -1,5 +1,8 @@
import SwiftUI
import simd
#if os(iOS) && EMG_PREVIEWS
import SnapshotPreferences
#endif
public extension AnyConditionalEffect {
/// An effect that emits smoke from the view.
@ -336,6 +339,7 @@ struct ContinuousParticleEffect_Previews: PreviewProvider {
}
static var previews: some View {
Group {
Preview()
.preferredColorScheme(.dark)
.previewDisplayName("Dark")
@ -352,14 +356,18 @@ struct ContinuousParticleEffect_Previews: PreviewProvider {
.preferredColorScheme(.dark)
.previewDisplayName("Particle Layer")
#if os(iOS)
#if os(iOS)
PreviewLayer()
.previewDisplayName("Emitter Layer")
#endif
#endif
PreviewAlt()
.preferredColorScheme(.dark)
.previewDisplayName("Emitter Dark")
}
#if os(iOS) && EMG_PREVIEWS
.emergeSnapshotPrecision(0)
#endif
}
}
#endif

View file

@ -1,4 +1,7 @@
import SwiftUI
#if os(iOS) && EMG_PREVIEWS
import SnapshotPreferences
#endif
public extension AnyTransition.MovingParts {
/// A transition that drops the view down from the top.
@ -280,6 +283,9 @@ struct Anvil_Previews: PreviewProvider {
.navigationBarHidden(true)
}
.environment(\.colorScheme, .dark)
#if os(iOS) && EMG_PREVIEWS
.emergeSnapshotPrecision(0)
#endif
}
}
#endif

View file

@ -1,4 +1,7 @@
import SwiftUI
#if os(iOS) && EMG_PREVIEWS
import SnapshotPreferences
#endif
public extension AnyTransition.MovingParts {
/// A transition that moves the view down with any overshoot resulting in an
@ -218,6 +221,9 @@ struct Bounce_Previews: PreviewProvider {
.navigationBarHidden(true)
}
.environment(\.colorScheme, .dark)
#if os(iOS) && EMG_PREVIEWS
.emergeSnapshotPrecision(0)
#endif
}
}
@ -290,6 +296,9 @@ struct Boing_2_Previews: PreviewProvider {
NavigationView {
Preview()
}
#if os(iOS) && EMG_PREVIEWS
.emergeSnapshotPrecision(0)
#endif
}
}
#endif

View file

@ -1,4 +1,7 @@
import SwiftUI
#if os(iOS) && EMG_PREVIEWS
import SnapshotPreferences
#endif
public extension AnyTransition.MovingParts {
/// A transition using a clockwise sweep around the centerpoint of the view.
@ -225,6 +228,9 @@ struct Clock_Previews: PreviewProvider {
.navigationBarHidden(true)
}
.environment(\.colorScheme, .dark)
#if os(iOS) && EMG_PREVIEWS
.emergeSnapshotPrecision(0)
#endif
}
}
#endif

View file

@ -1,4 +1,7 @@
import SwiftUI
#if os(iOS) && EMG_PREVIEWS
import SnapshotPreferences
#endif
public extension AnyTransition.MovingParts {
/// A transitions that shows the view by combining a diagonal wipe with a
@ -254,6 +257,9 @@ struct Glare_Previews: PreviewProvider {
.navigationBarHidden(true)
}
.environment(\.colorScheme, .dark)
#if os(iOS) && EMG_PREVIEWS
.emergeSnapshotPrecision(0)
#endif
}
}
#endif

View file

@ -1,4 +1,7 @@
import SwiftUI
#if os(iOS) && EMG_PREVIEWS
import SnapshotPreferences
#endif
public extension AnyTransition.MovingParts {
/// The direction from which to animate in during a `skid` transition's insertion.
@ -182,6 +185,9 @@ struct Skid_Previews: PreviewProvider {
.navigationBarHidden(true)
}
.environment(\.colorScheme, .dark)
#if os(iOS) && EMG_PREVIEWS
.emergeSnapshotPrecision(0)
#endif
}
}

View file

@ -1,4 +1,7 @@
import SwiftUI
#if os(iOS) && EMG_PREVIEWS
import SnapshotPreferences
#endif
public extension AnyTransition.MovingParts {
/// A transition that dissolves the view into many small particles.
@ -236,6 +239,9 @@ struct Vanish_Previews: PreviewProvider {
.navigationBarHidden(true)
}
.environment(\.colorScheme, .dark)
#if os(iOS) && EMG_PREVIEWS
.emergeSnapshotPrecision(0)
#endif
}
}
#endif