Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
6466926
Support Swift Package Manager (#126)
bfernandesbfs Aug 23, 2021
ed69601
Update project to Xcode 12.0 (#135)
bielikb Aug 23, 2021
5850750
Fix incorrect types for bundleResourcePath
alanzeino Aug 24, 2021
9c71a14
Revert the Podfile.lock removal from #126
alanzeino Aug 24, 2021
1b9d320
Update Cocoapods
alanzeino Aug 24, 2021
65f259b
Update FBSnapshotTestCaseDemo images for Xcode 12.5.1 and iOS 14
alanzeino Aug 24, 2021
511f302
Update to Swift 5.4
alanzeino Aug 24, 2021
4bc9f20
Update CHANGELOG for v7.0
alanzeino Aug 24, 2021
585eeb1
Update podspec for 7.0.0
alanzeino Aug 24, 2021
6743a70
Update podspec after public headers move in #126
alanzeino Aug 24, 2021
fece014
Update Cartfile.resolved for 7.0.0
alanzeino Aug 24, 2021
07c37dc
Update release doc
alanzeino Aug 24, 2021
d985579
Create Action (#151)
alanzeino Aug 25, 2021
c31f0ac
Update README.md
alanzeino Aug 25, 2021
27b03f8
Add a SwiftPM Demo Project for integration testing (#153)
alanzeino Aug 25, 2021
881d0b3
Update README.md
alanzeino Aug 25, 2021
3346c90
Fewer things to test in build.sh (#154)
alanzeino Aug 25, 2021
f53ac6b
Change package dep on demo project to local (#156)
alanzeino Aug 30, 2021
85b185b
Fixed typo in documentation of `FBSnapshotTestCase`: "that" → "than" …
Paul-van-Klaveren Aug 30, 2021
6ff475b
Adds Bazel Support V2 (#155)
tinder-maxwellelliott Sep 1, 2021
58e341a
Use xcbeautify (#158)
alanzeino Sep 1, 2021
ee61aa2
Update README.md
alanzeino Sep 3, 2021
981500c
Update README.md
alanzeino Sep 3, 2021
63899a5
Update README.md
alanzeino Sep 3, 2021
f3140d1
Lower Swift version requirement to 5.3 (#162)
alanzeino Sep 13, 2021
bce7520
Fix spelling mistake 'Test Hist' (#166)
mpdifran Oct 21, 2021
b258c50
Xcode 13 support (#150)
alanzeino Oct 21, 2021
5853c77
Fix all the paths for spm (#167)
alanzeino Oct 22, 2021
7b10770
Update version numbers
alanzeino Oct 22, 2021
9a8bab5
Add missing SwiftSupport.swift file to xcodeproj needed to publish Ca…
alanzeino Oct 22, 2021
7e9ae18
Fix deployment target in xcodeproj to resolve Carthage issues
alanzeino Oct 22, 2021
49b48bc
Update release docs
alanzeino Oct 22, 2021
444c218
Update README.md
alanzeino Oct 22, 2021
dba8610
Fix path to SwiftSupport.swift in BUILD.bazel (#170)
erikkerber Mar 10, 2022
47cdb5f
Update links to env var code in readme (#173)
iammike Mar 10, 2022
5ec4135
remove importing `CoreImage` (#169)
417-72KI Mar 10, 2022
71f1954
Add a bazelversion file (#176)
alanzeino Mar 16, 2022
57b023c
Adds link to XCTest in objc_library rule (#180)
maxwellE Jun 29, 2023
e4b8117
Update LibraryVsApplicationTestBundles.md
alanzeino Jan 9, 2025
0ed5bce
Update main.yml
reesebadazz2 Sep 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build --apple_platform_type=ios
1 change: 1 addition & 0 deletions .bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4.2.1
10 changes: 10 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
- name: First interaction
uses: actions/first-interaction@v1.3.0
with:
# Token for the repository. Can be passed in using {{ secrets.GITHUB_TOKEN }}
repo-token:
# Comment to post on an individual's first issue
issue-message: # optional
# Comment to post on an individual's first pull request
pr-message: # optional

4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ DerivedData
.idea/
*.hmap
*.xccheckout
.swiftpm/
Pods
FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemoTests/FailedSnapshotImages
iOSSnapshotTestCaseCarthageDemo/Carthage/Checkouts
iOSSnapshotTestCaseCarthageDemo/Carthage/Build
iOSSnapshotTestCaseCarthageDemo/Carthage/Build
bazel-*
29 changes: 29 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
load(
"@build_bazel_rules_swift//swift:swift.bzl",
"swift_library",
)

objc_library(
name = "iOSSnapshotTestCaseCore",
module_name = "iOSSnapshotTestCaseCore",
srcs = glob(["src/iOSSnapshotTestCaseCore/*.m", "src/iOSSnapshotTestCaseCore/Categories/*.h", "src/iOSSnapshotTestCaseCore/Categories/*.m"], allow_empty = False),
hdrs = glob(["src/iOSSnapshotTestCaseCore/Public/*.h"], allow_empty = False),
defines = [
"SWIFT_PACKAGE"
],
copts = [
"-Wno-deprecated-declarations"
],
sdk_frameworks = ["XCTest"],
visibility = ["//visibility:public"]
)

swift_library(
name = "iOSSnapshotTestCase",
module_name = "iOSSnapshotTestCase",
srcs = ["src/iOSSnapshotTestCase/SwiftSupport.swift"],
deps = [
":iOSSnapshotTestCaseCore"
],
visibility = ["//visibility:public"]
)
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

All notable changes to this project will be documented in this file.

## 8.0.0

- We fixed all the file path issues and renamed the targets from FBSnapshotTestCase to iOSSnapshotTestCase. There were a lot of confusing old legacy decisions lingering in the repo and it didn't make sense to keep using confusing naming or directory structures. If you use SPM you will have to use 'import iOSSnapshotTestCase'. Cocoapods and Carthage will continue to use 'import FBSnapshotTestCase'.
- Xcode 13 and iOS 15 support.
- Bazel support.

## 7.0.0

- Support for Swift Package Manager.
- Updated for Xcode 12.5 and Swift 5.4.

## 6.2.0

- Fixed issue where images without the screen scale in the file name were failing. ([#100](https://github.com/uber/ios-snapshot-test-case/pull/100))
Expand Down
144 changes: 68 additions & 76 deletions FBSnapshotTestCase.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1020"
LastUpgradeVersion = "1300"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1020"
LastUpgradeVersion = "1300"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
20 changes: 0 additions & 20 deletions FBSnapshotTestCaseDemo/Podfile.lock

This file was deleted.

38 changes: 38 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// swift-tools-version:5.3
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription

let package = Package(
name: "iOSSnapshotTestCase",
platforms: [
.iOS(.v10), .tvOS(.v10),
],
products: [
.library(
name: "iOSSnapshotTestCase",
type: .dynamic,
targets: [
"iOSSnapshotTestCase",
"iOSSnapshotTestCaseCore"
]
),
],
dependencies: [],
targets: [
.target(
name: "iOSSnapshotTestCase",
dependencies: ["iOSSnapshotTestCaseCore"]
),
.target(
name: "iOSSnapshotTestCaseCore",
exclude: ["Resources/FBSnapshotTestCase-Info.plist"],
publicHeadersPath: "Public"
),
.testTarget(
name: "iOSSnapshotTestCaseTests",
dependencies: ["iOSSnapshotTestCase"],
exclude: ["BUILD.bazel"],
resources: [.process("Resources")]
),
]
)
21 changes: 17 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# iOSSnapshotTestCase (previously [FBSnapshotTestCase](https://github.com/facebookarchive/ios-snapshot-test-case))

[![Build Status](https://travis-ci.org/uber/ios-snapshot-test-case.svg)](https://travis-ci.org/uber/ios-snapshot-test-case)
[![Build Status](https://github.com/uber/ios-snapshot-test-case/actions/workflows/main.yml/badge.svg?branch=main)](https://github.com/uber/ios-snapshot-test-case/actions)
[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/iOSSnapshotTestCase.svg)](https://img.shields.io/cocoapods/v/iOSSnapshotTestCase.svg)
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
[![Swift Package Manager](https://img.shields.io/badge/Swift_Package_Manager-compatible-orange?style=flat-square)](https://img.shields.io/badge/Swift_Package_Manager-compatible-orange?style=flat-square)

## What it does

Expand Down Expand Up @@ -48,20 +49,32 @@ If your test target is Objective-C only use `iOSSnapshotTestCase/Core` instead,
Add the following line to your Cartfile:

```carthage
github "uber/ios-snapshot-test-case" ~> 6.1.0
github "uber/ios-snapshot-test-case" ~> 8.0.0
```

#### Swift Package Manager

Add the following line to your `Package.swift`:

```spm
dependencies: [
.package(url: "https://github.com/uber/ios-snapshot-test-case.git", from: "8.0.0"),
],
```

...or integrate with Xcode via `File -> Swift Packages -> Add Package Dependency...` using the URL of the repository. We recommend using "Up to Next Major" with the Version field, as we use Semantic Versioning and only put breaking changes in major versions.

### Step 2: Setup Test Scheme
Replace "Tests" with the name of your test project.

1. There are [three ways](https://github.com/uber/ios-snapshot-test-case/blob/master/FBSnapshotTestCase/FBSnapshotTestCase.h#L19-L29) of setting reference image directories, the recommended one is to define `FB_REFERENCE_IMAGE_DIR` in your scheme. This should point to the directory where you want reference images to be stored. We normally use this:
1. There are [three ways](https://github.com/uber/ios-snapshot-test-case/blob/main/src/iOSSnapshotTestCaseCore/Public/FBSnapshotTestCase.h#L17-L31) of setting reference image directories, the recommended one is to define `FB_REFERENCE_IMAGE_DIR` in your scheme. This should point to the directory where you want reference images to be stored. We normally use this:

|Name|Value|
|:---|:----|
|`FB_REFERENCE_IMAGE_DIR`|`$(SOURCE_ROOT)/$(PROJECT_NAME)Tests/ReferenceImages`|
|`IMAGE_DIFF_DIR`|`$(SOURCE_ROOT)/$(PROJECT_NAME)Tests/FailureDiffs`|

Define the `IMAGE_DIFF_DIR` to the directory where you want to store diffs of failed snapshots. There are also [three ways](https://github.com/uber/ios-snapshot-test-case/blob/master/FBSnapshotTestCase/FBSnapshotTestCase.h#L34-L43) to set failed image diff directories.
Define the `IMAGE_DIFF_DIR` to the directory where you want to store diffs of failed snapshots. There are also [three ways](https://github.com/uber/ios-snapshot-test-case/blob/main/src/iOSSnapshotTestCaseCore/Public/FBSnapshotTestCase.h#L33-L45) to set failed image diff directories.

![](FBSnapshotTestCaseDemo/Scheme_FB_REFERENCE_IMAGE_DIR.png)

Expand Down
35 changes: 35 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "build_bazel_rules_apple",
sha256 = "0052d452af7742c8f3a4e0929763388a66403de363775db7e90adecb2ba4944b",
url = "https://github.com/bazelbuild/rules_apple/releases/download/0.31.3/rules_apple.0.31.3.tar.gz",
)

load(
"@build_bazel_rules_apple//apple:repositories.bzl",
"apple_rules_dependencies",
)

apple_rules_dependencies()

load(
"@build_bazel_rules_swift//swift:repositories.bzl",
"swift_rules_dependencies",
)

swift_rules_dependencies()

load(
"@build_bazel_rules_swift//swift:extras.bzl",
"swift_rules_extra_dependencies",
)

swift_rules_extra_dependencies()

load(
"@build_bazel_apple_support//lib:repositories.bzl",
"apple_support_dependencies",
)

apple_support_dependencies()
49 changes: 35 additions & 14 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,60 +8,81 @@ function ci_lib() {
-scheme "FBSnapshotTestCase iOS" \
-destination "platform=iOS Simulator,name=${NAME}" \
-sdk iphonesimulator \
build-for-testing
build-for-testing | xcbeautify
xcodebuild -project FBSnapshotTestCase.xcodeproj \
-scheme "FBSnapshotTestCase iOS" \
-destination "platform=iOS Simulator,name=${NAME}" \
-sdk iphonesimulator \
test-without-building
test-without-building | xcbeautify
}

function ci_demo() {
NAME=$1
pushd FBSnapshotTestCaseDemo
pushd demos/FBSnapshotTestCaseDemo
pod install
xcodebuild -workspace FBSnapshotTestCaseDemo.xcworkspace \
-scheme FBSnapshotTestCaseDemo \
-destination "platform=iOS Simulator,name=${NAME}" \
build-for-testing
build-for-testing | xcbeautify
xcodebuild -workspace FBSnapshotTestCaseDemo.xcworkspace \
-scheme FBSnapshotTestCaseDemo \
-destination "platform=iOS Simulator,name=${NAME}" \
test-without-building
test-without-building | xcbeautify
popd
}

function ci_demo_preprocessor() {
NAME=$1
pushd FBSnapshotTestCaseDemo
pushd demos/FBSnapshotTestCaseDemo
pod install
xcodebuild -workspace FBSnapshotTestCaseDemo.xcworkspace \
-scheme FBSnapshotTestCasePreprocessorDemo \
-destination "platform=iOS Simulator,name=${NAME}" \
build-for-testing
build-for-testing | xcbeautify
xcodebuild -workspace FBSnapshotTestCaseDemo.xcworkspace \
-scheme FBSnapshotTestCasePreprocessorDemo \
-destination "platform=iOS Simulator,name=${NAME}" \
test-without-building
test-without-building | xcbeautify
popd
}

function ci_carthage_demo() {
NAME=$1
pushd iOSSnapshotTestCaseCarthageDemo
carthage bootstrap
pushd demos/iOSSnapshotTestCaseCarthageDemo
carthage bootstrap --no-use-binaries --use-xcframeworks # we're using --no-use-binaries because carthage's archive doesn't yet create xcframeworks, and we're using --use-xcframeworks because of Xcode 12
xcodebuild -project iOSSnapshotTestCaseCarthageDemo.xcodeproj \
-scheme iOSSnapshotTestCaseCarthageDemo \
-destination "platform=iOS Simulator,name=${NAME}" \
build-for-testing
build-for-testing | xcbeautify
xcodebuild -project iOSSnapshotTestCaseCarthageDemo.xcodeproj \
-scheme iOSSnapshotTestCaseCarthageDemo \
-destination "platform=iOS Simulator,name=${NAME}" \
test-without-building
test-without-building | xcbeautify
popd
}

function ci_swiftpm_demo() {
NAME=$1
pushd demos/iOSSnapshotTestCaseSwiftPMDemo
xcodebuild -project iOSSnapshotTestCaseSwiftPMDemo.xcodeproj \
-scheme "iOSSnapshotTestCaseSwiftPMDemo (iOS)" \
-destination "platform=iOS Simulator,name=${NAME}" \
build-for-testing | xcbeautify
xcodebuild -project iOSSnapshotTestCaseSwiftPMDemo.xcodeproj \
-scheme "iOSSnapshotTestCaseSwiftPMDemo (iOS)" \
-destination "platform=iOS Simulator,name=${NAME}" \
test-without-building | xcbeautify
popd
}

function test_bazel() {
bazelisk test //src/iOSSnapshotTestCaseTests:iOSSnapshotTestCaseTests --test_output=all
}

ci_lib "iPhone 8" && ci_demo "iPhone 8" && ci_demo_preprocessor "iPhone 8"
ci_lib "iPhone 11" && ci_demo "iPhone 11" && ci_demo_preprocessor "iPhone 11"
ci_lib "iPhone 8" && ci_carthage_demo "iPhone 8"
ci_lib "iPhone 11" && ci_carthage_demo "iPhone 11"
ci_carthage_demo "iPhone 8"
ci_carthage_demo "iPhone 11"
ci_swiftpm_demo "iPhone 8"
ci_swiftpm_demo "iPhone 11"
test_bazel
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@
INFOPLIST_FILE = "FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemo-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.facebook.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_BUNDLE_IDENTIFIER = com.facebook.FBSnapshotTestCaseDemo;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
Expand All @@ -670,7 +670,7 @@
INFOPLIST_FILE = "FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemo-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.facebook.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_BUNDLE_IDENTIFIER = com.facebook.FBSnapshotTestCaseDemo;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ - (void)testViewSnapshot
FBSnapshotVerifyLayer(redView.layer, nil);
}

- (void)testViewSnapshotWithVisualEffects
/// Disabled due to incompatibility with github actions runner simulator?
- (void)_testViewSnapshotWithVisualEffects
{
if ([UIVisualEffect class]) {
UIVisualEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
platform :ios, '14.5'

use_frameworks!

target :'FBSnapshotTestCaseDemoTests' do
pod 'iOSSnapshotTestCase', :path => '..'
pod 'iOSSnapshotTestCase', :path => '../..'
end

target :'FBSnapshotTestCasePreprocessorDemoTests' do
pod 'iOSSnapshotTestCase', :path => '..'
pod 'iOSSnapshotTestCase', :path => '../..'
end

post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '5.1'
config.build_settings['SWIFT_VERSION'] = '5.4'
end
end
end
Loading