facebookarchive / ios-snapshot-test-case

Snapshot view unit tests for iOS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Swift support

dzenbot opened this issue · comments

Has anyone managed to use this framework directly using XCTest with Swift?

I get the same problem pointed out by @squarefrog in #69 which is more than 1 year old.

Using these simple wrapper for Objective-C macros did part of the job:

@implementation FBSnapshotTestCase (SwiftAdditions)

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

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

@end

But I keep getting "The operation couldn’t be completed. Permission denied" when attempting to save the image reference to disk.

Actually never mind. This framework works just great with Swift!

I fixed the permission error by executing the tests from within the host app target, instead of running the test target directly 🤦