我已经在我的iOS项目中的测试文件中获得了fbsnapshottestcase库和子类FBSnapshotTestCase
。但是,如果我尝试调用FBSnapshotVerifyView
,我会收到找不到错误的方法。
答案 0 :(得分:7)
您可以制作扩展程序并将其导入桥文件中:
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
答案 1 :(得分:1)
我今天在swift开始的新项目中遇到了同样的问题。此外,我分叉回购修复它。你会在那里找到它:
https://github.com/delannoyk/ios-snapshot-test-case
您可以将其添加为Pod:
target "Tests" do
pod 'FBSnapshotTestCase', :git => 'https://github.com/delannoyk/ios-snapshot-test-case'
end