diff --git a/.travis.yml b/.travis.yml index 1e79af3..f34ae22 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: objective-c -osx_image: xcode7.3 +osx_image: xcode8 before_script: - gem install cocoapods -v 1.0.0 --no-ri --no-rdoc script: diff --git a/CHANGELOG.md b/CHANGELOG.md index 4028afd..9545983 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,15 @@ All notable changes to this project will be documented in this file. +## 2.1.4 + + - Swift 3 support (#194) + - Replace big macro with Objective-C method for easier debugging (#180) + +## 2.1.3 + + - Allow to compile with Xcode 7 and Xcode 8 Swift 2.3 (#179) + ## 2.1.2 - Disabled Bitcode for tvOS target (#169) diff --git a/FBSnapshotTestCase.podspec b/FBSnapshotTestCase.podspec index 78cf432..eb557aa 100644 --- a/FBSnapshotTestCase.podspec +++ b/FBSnapshotTestCase.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "FBSnapshotTestCase" - s.version = "2.1.2" + s.version = "2.1.4" s.summary = "Snapshot view unit tests for iOS" s.description = <<-DESC A "snapshot test case" takes a configured UIView or CALayer diff --git a/FBSnapshotTestCase.xcodeproj/project.pbxproj b/FBSnapshotTestCase.xcodeproj/project.pbxproj index 67ca509..fa4a510 100644 --- a/FBSnapshotTestCase.xcodeproj/project.pbxproj +++ b/FBSnapshotTestCase.xcodeproj/project.pbxproj @@ -344,9 +344,11 @@ }; B31987EF1AB782D000B0A900 = { CreatedOnToolsVersion = 6.1.1; + LastSwiftMigration = 0800; }; B31987FA1AB782D100B0A900 = { CreatedOnToolsVersion = 6.1.1; + LastSwiftMigration = 0800; }; }; }; @@ -501,6 +503,7 @@ SDKROOT = appletvos; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = 3; TVOS_DEPLOYMENT_TARGET = 9.0; }; @@ -532,6 +535,7 @@ PRODUCT_NAME = FBSnapshotTestCase; SDKROOT = appletvos; SKIP_INSTALL = YES; + SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = 3; TVOS_DEPLOYMENT_TARGET = 9.0; }; @@ -678,6 +682,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.facebook.FBSnapshotTestCase; PRODUCT_NAME = FBSnapshotTestCase; SKIP_INSTALL = YES; + SWIFT_VERSION = 3.0; }; name = Debug; }; @@ -705,6 +710,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.facebook.FBSnapshotTestCase; PRODUCT_NAME = FBSnapshotTestCase; SKIP_INSTALL = YES; + SWIFT_VERSION = 3.0; }; name = Release; }; @@ -723,6 +729,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.facebook.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; }; name = Debug; }; @@ -737,6 +744,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.facebook.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; }; name = Release; }; diff --git a/FBSnapshotTestCase/FBSnapshotTestCase.h b/FBSnapshotTestCase/FBSnapshotTestCase.h index f533e0c..6b28d09 100644 --- a/FBSnapshotTestCase/FBSnapshotTestCase.h +++ b/FBSnapshotTestCase/FBSnapshotTestCase.h @@ -62,43 +62,9 @@ #define FBSnapshotVerifyViewOrLayerWithOptions(what__, viewOrLayer__, identifier__, suffixes__, tolerance__) \ { \ - NSString *referenceImageDirectory = [self getReferenceImageDirectoryWithDefault:(@ FB_REFERENCE_IMAGE_DIR)]; \ - XCTAssertNotNil(referenceImageDirectory, @"Missing value for referenceImagesDirectory - Set FB_REFERENCE_IMAGE_DIR as Environment variable in your scheme.");\ - XCTAssertTrue((suffixes__.count > 0), @"Suffixes set cannot be empty %@", suffixes__); \ - \ - BOOL testSuccess__ = NO; \ - NSError *error__ = nil; \ - NSMutableArray *errors__ = [NSMutableArray array]; \ - \ - if (self.recordMode) { \ - \ - NSString *referenceImagesDirectory__ = [NSString stringWithFormat:@"%@%@", referenceImageDirectory, suffixes__.firstObject]; \ - BOOL referenceImageSaved__ = [self compareSnapshotOf ## what__ :(viewOrLayer__) referenceImagesDirectory:referenceImagesDirectory__ identifier:(identifier__) tolerance:(tolerance__) error:&error__]; \ - if (!referenceImageSaved__) { \ - [errors__ addObject:error__]; \ - } \ - } else { \ - \ - for (NSString *suffix__ in suffixes__) { \ - NSString *referenceImagesDirectory__ = [NSString stringWithFormat:@"%@%@", referenceImageDirectory, suffix__]; \ - BOOL referenceImageAvailable = [self referenceImageRecordedInDirectory:referenceImagesDirectory__ identifier:(identifier__) error:&error__]; \ - \ - if (referenceImageAvailable) { \ - BOOL comparisonSuccess__ = [self compareSnapshotOf ## what__ :(viewOrLayer__) referenceImagesDirectory:referenceImagesDirectory__ identifier:(identifier__) tolerance:(tolerance__) error:&error__]; \ - [errors__ removeAllObjects]; \ - if (comparisonSuccess__) { \ - testSuccess__ = YES; \ - break; \ - } else { \ - [errors__ addObject:error__]; \ - } \ - } else { \ - [errors__ addObject:error__]; \ - } \ - } \ - } \ - XCTAssertTrue(testSuccess__, @"Snapshot comparison failed: %@", errors__.firstObject); \ - XCTAssertFalse(self.recordMode, @"Test ran in record mode. Reference image is now saved. Disable record mode to perform an actual snapshot comparison!"); \ + NSString *errorDescription = [self snapshotVerifyViewOrLayer:viewOrLayer__ identifier:identifier__ suffixes:suffixes__ tolerance:tolerance__]; \ + BOOL noErrors = (errorDescription == nil); \ + XCTAssertTrue(noErrors, @"%@", errorDescription); \ } @@ -148,6 +114,19 @@ - (void)setUp NS_REQUIRES_SUPER; - (void)tearDown NS_REQUIRES_SUPER; +/** + Performs the comparison or records a snapshot of the layer if recordMode is YES. + @param viewOrLayer The UIView or CALayer to snapshot + @param identifier An optional identifier, used if there are multiple snapshot tests in a given -test method. + @param suffixes An NSOrderedSet of strings for the different suffixes + @param tolerance The percentage difference to still count as identical - 0 mean pixel perfect, 1 means I don't care + @returns nil if the comparison (or saving of the reference image) succeeded. Otherwise it contains an error description. + */ +- (NSString *)snapshotVerifyViewOrLayer:(id)viewOrLayer + identifier:(NSString *)identifier + suffixes:(NSOrderedSet *)suffixes + tolerance:(CGFloat)tolerance; + /** Performs the comparison or records a snapshot of the layer if recordMode is YES. @param layer The Layer to snapshot diff --git a/FBSnapshotTestCase/FBSnapshotTestCase.m b/FBSnapshotTestCase/FBSnapshotTestCase.m index 13eeece..24bc5c4 100644 --- a/FBSnapshotTestCase/FBSnapshotTestCase.m +++ b/FBSnapshotTestCase/FBSnapshotTestCase.m @@ -65,6 +65,62 @@ - (void)setUsesDrawViewHierarchyInRect:(BOOL)usesDrawViewHierarchyInRect #pragma mark - Public API +- (NSString *)snapshotVerifyViewOrLayer:(id)viewOrLayer + identifier:(NSString *)identifier + suffixes:(NSOrderedSet *)suffixes + tolerance:(CGFloat)tolerance +{ + if (nil == viewOrLayer) { + return @"Object to be snapshotted must not be nil"; + } + NSString *referenceImageDirectory = [self getReferenceImageDirectoryWithDefault:(@ FB_REFERENCE_IMAGE_DIR)]; + if (referenceImageDirectory == nil) { + return @"Missing value for referenceImagesDirectory - Set FB_REFERENCE_IMAGE_DIR as Environment variable in your scheme."; + } + if (suffixes.count == 0) { + return [NSString stringWithFormat:@"Suffixes set cannot be empty %@", suffixes]; + } + + BOOL testSuccess = NO; + NSError *error = nil; + NSMutableArray *errors = [NSMutableArray array]; + + if (self.recordMode) { + NSString *referenceImagesDirectory = [NSString stringWithFormat:@"%@%@", referenceImageDirectory, suffixes.firstObject]; + BOOL referenceImageSaved = [self _compareSnapshotOfViewOrLayer:viewOrLayer referenceImagesDirectory:referenceImagesDirectory identifier:(identifier) tolerance:tolerance error:&error]; + if (!referenceImageSaved) { + [errors addObject:error]; + } + } else { + for (NSString *suffix in suffixes) { + NSString *referenceImagesDirectory = [NSString stringWithFormat:@"%@%@", referenceImageDirectory, suffix]; + BOOL referenceImageAvailable = [self referenceImageRecordedInDirectory:referenceImagesDirectory identifier:(identifier) error:&error]; + + if (referenceImageAvailable) { + BOOL comparisonSuccess = [self _compareSnapshotOfViewOrLayer:viewOrLayer referenceImagesDirectory:referenceImagesDirectory identifier:identifier tolerance:tolerance error:&error]; + [errors removeAllObjects]; + if (comparisonSuccess) { + testSuccess = YES; + break; + } else { + [errors addObject:error]; + } + } else { + [errors addObject:error]; + } + } + } + + if (!testSuccess) { + return [NSString stringWithFormat:@"Snapshot comparison failed: %@", errors.firstObject]; + } + if (self.recordMode) { + return @"Test ran in record mode. Reference image is now saved. Disable record mode to perform an actual snapshot comparison!"; + } + + return nil; +} + - (BOOL)compareSnapshotOfLayer:(CALayer *)layer referenceImagesDirectory:(NSString *)referenceImagesDirectory identifier:(NSString *)identifier diff --git a/FBSnapshotTestCase/FBSnapshotTestController.h b/FBSnapshotTestCase/FBSnapshotTestController.h index d648a1e..3853a87 100644 --- a/FBSnapshotTestCase/FBSnapshotTestController.h +++ b/FBSnapshotTestCase/FBSnapshotTestController.h @@ -89,7 +89,7 @@ extern NSString *const FBDiffedImageKey; @param layer The Layer to snapshot. @param selector The test method being run. @param identifier An optional identifier, used is there are muliptle snapshot tests in a given -test method. - @param error An error to log in an XCTAssert() macro if the method fails (missing reference image, images differ, etc). + @param errorPtr An error to log in an XCTAssert() macro if the method fails (missing reference image, images differ, etc). @returns YES if the comparison (or saving of the reference image) succeeded. */ - (BOOL)compareSnapshotOfLayer:(CALayer *)layer @@ -102,7 +102,7 @@ extern NSString *const FBDiffedImageKey; @param view The view to snapshot. @param selector The test method being run. @param identifier An optional identifier, used is there are muliptle snapshot tests in a given -test method. - @param error An error to log in an XCTAssert() macro if the method fails (missing reference image, images differ, etc). + @param errorPtr An error to log in an XCTAssert() macro if the method fails (missing reference image, images differ, etc). @returns YES if the comparison (or saving of the reference image) succeeded. */ - (BOOL)compareSnapshotOfView:(UIView *)view @@ -112,7 +112,7 @@ extern NSString *const FBDiffedImageKey; /** Performs the comparison of a view or layer. - @param view The view or layer to snapshot. + @param viewOrLayer The view or layer to snapshot. @param selector The test method being run. @param identifier An optional identifier, used is there are muliptle snapshot tests in a given -test method. @param tolerance The percentage of pixels that can differ and still be considered 'identical' diff --git a/FBSnapshotTestCase/SwiftSupport.swift b/FBSnapshotTestCase/SwiftSupport.swift index af689d5..84eb94f 100644 --- a/FBSnapshotTestCase/SwiftSupport.swift +++ b/FBSnapshotTestCase/SwiftSupport.swift @@ -8,6 +8,64 @@ * */ +#if swift(>=3) + public extension FBSnapshotTestCase { + public func FBSnapshotVerifyView(_ view: UIView, identifier: String = "", suffixes: NSOrderedSet = FBSnapshotTestCaseDefaultSuffixes(), tolerance: CGFloat = 0, file: StaticString = #file, line: UInt = #line) { + FBSnapshotVerifyViewOrLayer(view, identifier: identifier, suffixes: suffixes, tolerance: tolerance, file: file, line: line) + } + + public func FBSnapshotVerifyLayer(_ layer: CALayer, identifier: String = "", suffixes: NSOrderedSet = FBSnapshotTestCaseDefaultSuffixes(), tolerance: CGFloat = 0, file: StaticString = #file, line: UInt = #line) { + FBSnapshotVerifyViewOrLayer(layer, identifier: identifier, suffixes: suffixes, tolerance: tolerance, file: file, line: line) + } + + private func FBSnapshotVerifyViewOrLayer(_ viewOrLayer: AnyObject, identifier: String = "", suffixes: NSOrderedSet = FBSnapshotTestCaseDefaultSuffixes(), tolerance: CGFloat = 0, file: StaticString = #file, line: UInt = #line) { + let envReferenceImageDirectory = self.getReferenceImageDirectory(withDefault: FB_REFERENCE_IMAGE_DIR) + var error: NSError? + var comparisonSuccess = false + + if let envReferenceImageDirectory = envReferenceImageDirectory { + for suffix in suffixes { + let referenceImagesDirectory = "\(envReferenceImageDirectory)\(suffix)" + if viewOrLayer.isKind(of: UIView.self) { + do { + try compareSnapshot(of: viewOrLayer as! UIView, referenceImagesDirectory: referenceImagesDirectory, identifier: identifier, tolerance: tolerance) + comparisonSuccess = true + } catch let error1 as NSError { + error = error1 + comparisonSuccess = false + } + } else if viewOrLayer.isKind(of: CALayer.self) { + do { + try compareSnapshot(of: viewOrLayer as! CALayer, referenceImagesDirectory: referenceImagesDirectory, identifier: identifier, tolerance: tolerance) + comparisonSuccess = true + } catch let error1 as NSError { + error = error1 + comparisonSuccess = false + } + } else { + assertionFailure("Only UIView and CALayer classes can be snapshotted") + } + + assert(recordMode == false, message: "Test ran in record mode. Reference image is now saved. Disable record mode to perform an actual snapshot comparison!", file: file, line: line) + + if comparisonSuccess || recordMode { + break + } + + assert(comparisonSuccess, message: "Snapshot comparison failed: \(error)", file: file, line: line) + } + } else { + XCTFail("Missing value for referenceImagesDirectory - Set FB_REFERENCE_IMAGE_DIR as Environment variable in your scheme.") + } + } + + func assert(_ assertion: Bool, message: String, file: StaticString, line: UInt) { + if !assertion { + XCTFail(message, file: file, line: line) + } + } + } +#else public extension FBSnapshotTestCase { public func FBSnapshotVerifyView(view: UIView, identifier: String = "", suffixes: NSOrderedSet = FBSnapshotTestCaseDefaultSuffixes(), tolerance: CGFloat = 0, colorTolerance: CGFloat = 0, file: StaticString = #file, line: UInt = #line) { FBSnapshotVerifyViewOrLayer(view, identifier: identifier, suffixes: suffixes, tolerance: tolerance, colorTolerance: colorTolerance,file: file, line: line) @@ -64,3 +122,4 @@ public extension FBSnapshotTestCase { } } } +#endif diff --git a/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemo.xcodeproj/project.pbxproj b/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemo.xcodeproj/project.pbxproj index c59ddfa..b198a70 100644 --- a/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemo.xcodeproj/project.pbxproj +++ b/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemo.xcodeproj/project.pbxproj @@ -177,12 +177,15 @@ isa = PBXNativeTarget; buildConfigurationList = B30449281AB794320067C75D /* Build configuration list for PBXNativeTarget "FBSnapshotTestCaseDemoTests" */; buildPhases = ( - 2446417C513BDAF88B9890FC /* 📦 Check Pods Manifest.lock */, + EEBCF471BAA9F698AD39E48C /* [CP] Check Pods Manifest.lock */, + 2446417C513BDAF88B9890FC /* [CP] Check Pods Manifest.lock */, B30449171AB794320067C75D /* Sources */, B30449181AB794320067C75D /* Frameworks */, B30449191AB794320067C75D /* Resources */, - EB64CD802D89DDA691FA7827 /* 📦 Embed Pods Frameworks */, - 30B7BE4963F35A6D89E72AFF /* 📦 Copy Pods Resources */, + EB64CD802D89DDA691FA7827 /* [CP] Embed Pods Frameworks */, + 30B7BE4963F35A6D89E72AFF /* [CP] Copy Pods Resources */, + 185D9F73B9CAAE68941B87AB /* 📦 Embed Pods Frameworks */, + E1316CB9B2C08A51D1D31909 /* 📦 Copy Pods Resources */, ); buildRules = ( ); @@ -206,9 +209,11 @@ TargetAttributes = { B30449011AB794320067C75D = { CreatedOnToolsVersion = 6.1.1; + LastSwiftMigration = 0800; }; B304491A1AB794320067C75D = { CreatedOnToolsVersion = 6.1.1; + LastSwiftMigration = 0800; TestTargetID = B30449011AB794320067C75D; }; }; @@ -253,14 +258,29 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 2446417C513BDAF88B9890FC /* 📦 Check Pods Manifest.lock */ = { + 185D9F73B9CAAE68941B87AB /* 📦 Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); - name = "📦 Check Pods Manifest.lock"; + name = "📦 Embed Pods Frameworks"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-FBSnapshotTestCaseDemoTests/Pods-FBSnapshotTestCaseDemoTests-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + 2446417C513BDAF88B9890FC /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Check Pods Manifest.lock"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; @@ -268,7 +288,22 @@ shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; showEnvVarsInLog = 0; }; - 30B7BE4963F35A6D89E72AFF /* 📦 Copy Pods Resources */ = { + 30B7BE4963F35A6D89E72AFF /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Copy Pods Resources"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-FBSnapshotTestCaseDemoTests/Pods-FBSnapshotTestCaseDemoTests-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; + E1316CB9B2C08A51D1D31909 /* 📦 Copy Pods Resources */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -283,14 +318,14 @@ shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-FBSnapshotTestCaseDemoTests/Pods-FBSnapshotTestCaseDemoTests-resources.sh\"\n"; showEnvVarsInLog = 0; }; - EB64CD802D89DDA691FA7827 /* 📦 Embed Pods Frameworks */ = { + EB64CD802D89DDA691FA7827 /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); - name = "📦 Embed Pods Frameworks"; + name = "[CP] Embed Pods Frameworks"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; @@ -298,6 +333,21 @@ shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-FBSnapshotTestCaseDemoTests/Pods-FBSnapshotTestCaseDemoTests-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; + EEBCF471BAA9F698AD39E48C /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Check Pods Manifest.lock"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; + showEnvVarsInLog = 0; + }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -427,6 +477,7 @@ INFOPLIST_FILE = "FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemo-Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; }; name = Debug; }; @@ -438,6 +489,7 @@ INFOPLIST_FILE = "FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemo-Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; }; name = Release; }; @@ -458,6 +510,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 3.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/FBSnapshotTestCaseDemo.app/FBSnapshotTestCaseDemo"; }; name = Debug; @@ -474,6 +527,7 @@ INFOPLIST_FILE = "FBSnapshotTestCaseDemoTests/FBSnapshotTestCaseDemoTests-Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/FBSnapshotTestCaseDemo.app/FBSnapshotTestCaseDemo"; }; name = Release; diff --git a/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemoTests/FBSnapshotTestCaseSwiftTests.swift b/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemoTests/FBSnapshotTestCaseSwiftTests.swift index a3ef2e6..95c7d8d 100644 --- a/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemoTests/FBSnapshotTestCaseSwiftTests.swift +++ b/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemoTests/FBSnapshotTestCaseSwiftTests.swift @@ -18,7 +18,7 @@ class FBSnapshotTestCaseSwiftTest: FBSnapshotTestCase { func testExample() { let view = UIView(frame: CGRect(x: 0, y: 0, width: 64, height: 64)) - view.backgroundColor = UIColor.blueColor() + view.backgroundColor = UIColor.blue FBSnapshotVerifyView(view) FBSnapshotVerifyLayer(view.layer) } diff --git a/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemoTests/ReferenceImages_64/FBSnapshotTestCaseDemoTests/testViewSnapshotWithVisualEffects@2x.png b/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemoTests/ReferenceImages_64/FBSnapshotTestCaseDemoTests/testViewSnapshotWithVisualEffects@2x.png index b2316d3..cc503fd 100644 Binary files a/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemoTests/ReferenceImages_64/FBSnapshotTestCaseDemoTests/testViewSnapshotWithVisualEffects@2x.png and b/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemoTests/ReferenceImages_64/FBSnapshotTestCaseDemoTests/testViewSnapshotWithVisualEffects@2x.png differ diff --git a/FBSnapshotTestCaseDemo/Podfile b/FBSnapshotTestCaseDemo/Podfile index 7dbd397..a45cfe1 100644 --- a/FBSnapshotTestCaseDemo/Podfile +++ b/FBSnapshotTestCaseDemo/Podfile @@ -7,4 +7,10 @@ target :'FBSnapshotTestCaseDemoTests' do pod 'FBSnapshotTestCase', :path => '..' end - +post_install do |installer| + installer.pods_project.targets.each do |target| + target.build_configurations.each do |config| + config.build_settings['SWIFT_VERSION'] = '3.0' + end + end +end diff --git a/FBSnapshotTestCaseDemo/Podfile.lock b/FBSnapshotTestCaseDemo/Podfile.lock index 100e98f..6a1f6ea 100644 --- a/FBSnapshotTestCaseDemo/Podfile.lock +++ b/FBSnapshotTestCaseDemo/Podfile.lock @@ -1,8 +1,8 @@ PODS: - - FBSnapshotTestCase (2.1.2): - - FBSnapshotTestCase/SwiftSupport (= 2.1.2) - - FBSnapshotTestCase/Core (2.1.2) - - FBSnapshotTestCase/SwiftSupport (2.1.2): + - FBSnapshotTestCase (2.1.4): + - FBSnapshotTestCase/SwiftSupport (= 2.1.4) + - FBSnapshotTestCase/Core (2.1.4) + - FBSnapshotTestCase/SwiftSupport (2.1.4): - FBSnapshotTestCase/Core DEPENDENCIES: @@ -13,8 +13,8 @@ EXTERNAL SOURCES: :path: ".." SPEC CHECKSUMS: - FBSnapshotTestCase: 918c55861356ee83aee7843d759f55a18ff6982b + FBSnapshotTestCase: 094f9f314decbabe373b87cc339bea235a63e07a -PODFILE CHECKSUM: f0c8c3073f8e31e4718d87d66744e7fa5953f5c4 +PODFILE CHECKSUM: 45453db5a1ae2809f44dda015540cc64c789c71c -COCOAPODS: 1.0.0 +COCOAPODS: 1.0.1 diff --git a/README.md b/README.md index bc23b83..4317003 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,9 @@ Installation with CocoaPods |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. ![](FBSnapshotTestCaseDemo/Scheme_FB_REFERENCE_IMAGE_DIR.png)