ios - 使用 Objective-C 进行 FaSTLane 快照

标签 ios screenshot snapshot fastlane

我正在尝试使用 FaSTLane 使用快照工具来截取我的应用程序的屏幕截图。然而,到 Objective-C 的转换似乎无法正常工作。我已将 Project-Swift.h 导入到 ProjectUITests.m 文件中,并包含以下代码:

SnapshotHelper *snapshotHelper = [[SnapshotHelper alloc] init];
[snapshotHelper setLanguage:app];
[snapshotHelper snapshot:@"01Homescreen" waitForLoadingIndicator:YES];

但是,当我在命令行中运行命令“snapshot”时,出现以下错误:

Testing failed:
Use of undeclared identifier 'SnapshotHelper'
Use of undeclared identifier 'snapshotHelper'

(1 failure)
[12:14:52]: Exit status: 65
[12:14:52]: Tests failed - check out the log above

所以我的问题是,如何让 SnapshotHelper.swift 文件在我的 ProjectUITests.m 文件中成功运行?

最佳答案

我必须更改 SnapshotHelper.swift 文件:

var deviceLanguage = ""

@objc class SnapshotHelper : NSObject { // <--- add this

@available(*, deprecated, message="use setupSnapshot: instead")
class func setLanguage(app: XCUIApplication) {
    setupSnapshot(app)
}

...

} // ...@objc class

(这是 github 上的相关问题: https://github.com/fastlane/snapshot/issues/228 )

有时我的 Xcode 不会为我创建桥接 header 。最简单的解决方法是从项目中删除 swift 文件并再次添加它。通常 Xcode 会询问我是否想要桥接 header 。

最终,您可能需要转到目标的“build设置”> Apple LLVM 7.0 - 语言 - 模块 > 启用的模块(C 和 Objective-C)= YES。

关于ios - 使用 Objective-C 进行 FaSTLane 快照,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34617691/

相关文章:

linux - 操作系统上的全系统快照

ios - 我在 Xcode : @interface for 'AppDelegate' declares the selector 'performSegueWithIdentifier:sender:' 中收到此错误

elasticsearch - Elasticsearch快照恢复另一个集群

ubuntu - AWS 实例的每小时备份

javascript - 使用 javascript 截取引导模式的屏幕截图

qt - Qt-Window 一小部分的截图

macos - 我可以在 QuickTime Player 10 中设置屏幕截图的尺寸吗

ios - 如何检测 ios 中的 admob 横幅广告

ios - 将文件从 ios 应用程序传输到 PC 上运行的应用程序

ios - 印象笔记 API : How to upload a note with pure ENML instead of plain text