Can you use the FBSnapshottestcase library with Swift?

I have fbsnapshottestcase library and subclasses FBSnapshotTestCase

in a test file that I have in my iOS project. However, if I try to call FBSnapshotVerifyView

, I get a method that didn't find an error.

+3


source to share


2 answers


I had the same problem today for a new project that I started quickly. Also, I forked the repo to fix this. You will find it there:

https://github.com/delannoyk/ios-snapshot-test-case



You can add it as a Pod:

 target "Tests" do
   pod 'FBSnapshotTestCase', :git => 'https://github.com/delannoyk/ios-snapshot-test-case'
 end

      

+1


source


You can make an extension and import it into a bridge file:

FBSnapshotTestCase + SwiftAdditions.h:

#import <Foundation/Foundation.h>
#import <FBSnapshotTestCase/FBSnapshotTestCase.h>

@interface FBSnapshotTestCase (SwiftAdditions)

- (void) snapshotVerifyView:(UIView *)view withIdentifier:(NSString *)identifier;
- (void) snapshotVerifyLayer:(CALayer *)layer withIdentifier:(NSString *)identifier;

@end

      



FBSnapshotTestCase + SwiftAdditions.m:

#import "FBSnapshotTestCase+SwiftAdditions.h"

@implementation FBSnapshotTestCase (SwiftAdditions)

- (void) snapshotVerifyView:(UIView *)view withIdentifier:(NSString *)identifier
{
    FBSnapshotVerifyView(view, identifier);
}

- (void) snapshotVerifyLayer:(CALayer *)layer withIdentifier:(NSString *)identifier
{
    FBSnapshotVerifyLayer(layer, identifier);
}

@end

      

+7


source







All Articles