Reputation: 3293
I am attempting to use Fastlane to take screenshots of my app using the snapshot tool. However The conversion to Objective-C doesn't appear to be working correctly. I have Project-Swift.h imported into my ProjectUITests.m file, and I have included the following code:
SnapshotHelper *snapshotHelper = [[SnapshotHelper alloc] init];
[snapshotHelper setLanguage:app];
[snapshotHelper snapshot:@"01Homescreen" waitForLoadingIndicator:YES];
However, when I run the command "snapshot" in the command line, I get the following errors:
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
So my question is, how do I get the SnapshotHelper.swift file to run successfully in my ProjectUITests.m file?
Upvotes: 2
Views: 2108
Reputation: 4745
I had to change the SnapshotHelper.swift file:
var deviceLanguage = ""
@objc class SnapshotHelper : NSObject { // <--- add this
@available(*, deprecated, message="use setupSnapshot: instead")
class func setLanguage(app: XCUIApplication) {
setupSnapshot(app)
}
...
} // ...@objc class
(Here is the related issue on github: https://github.com/fastlane/snapshot/issues/228)
From time to time my Xcode did not create the bridging headers for me. The easiest work around for that was to remove the swift file from the project and add it again. Usually then Xcode asked whether I want the bridging headers.
Eventually you may need to go to your target's Build Settings > Apple LLVM 7.0 - Language - Modules > Enabled Modules (C and Objective-C) = YES .
Upvotes: 2