objective-c - 您可以将 FBSnapshottestcase 库与 Swift 一起使用吗?

标签 objective-c swift xcode6

我有 fbsnapshottestcase库和子类 FBSnapshotTestCase 在我的 iOS 项目中的测试文件中。但是,如果我尝试调用 FBSnapshotVerifyView,我会收到一个方法未找到错误。

最佳答案

您可以制作扩展并将其导入到桥接文件中:

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

关于objective-c - 您可以将 FBSnapshottestcase 库与 Swift 一起使用吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27021323/

相关文章:

objective-c - Mac OS X 应用程序在其窗口没有焦点时速度变慢

ios - Objective-C 应该在使用后将 Arrays 设置为 nil 吗?

ios - 如何在 Swift 中解释从 CMSampleBuffer 派生的像素数组

ios - 为什么从标签栏 Controller 推送时我的 View Controller 是黑色的?

objective-c - 如果 HTML 中不存在 <html>、<head> 和 <body>,如何创建它们?

iOS : Customizing TableViewCell - Initializing Custom Cell

uitableview - Swift:将 UITableViewCell 标签传递给新的 ViewController

ios - 在 Swift 中为我的函数实现更通用的方法

xcode - 在 Xcode6 中将 Swift 文件导入其他 Swift 文件

xcode - 不同颜色的 currentPageIndicatorTintColor Swift Xcode