snapshot/lib/assets/SnapshotHelper.swift in fastlane-2.124.0.beta.20190528200017 vs snapshot/lib/assets/SnapshotHelper.swift in fastlane-2.124.0.beta.20190529200025
- old
+ new
@@ -68,72 +68,72 @@
static var screenshotsDirectory: URL? {
return cacheDirectory?.appendingPathComponent("screenshots", isDirectory: true)
}
open class func setupSnapshot(_ app: XCUIApplication, waitForAnimations: Bool = true) {
-
+
Snapshot.app = app
Snapshot.waitForAnimations = waitForAnimations
do {
let cacheDir = try pathPrefix()
Snapshot.cacheDirectory = cacheDir
setLanguage(app)
setLocale(app)
setLaunchArguments(app)
} catch let error {
- print(error)
+ NSLog(error.localizedDescription)
}
}
class func setLanguage(_ app: XCUIApplication) {
guard let cacheDirectory = self.cacheDirectory else {
- print("CacheDirectory is not set - probably running on a physical device?")
+ NSLog("CacheDirectory is not set - probably running on a physical device?")
return
}
-
+
let path = cacheDirectory.appendingPathComponent("language.txt")
do {
let trimCharacterSet = CharacterSet.whitespacesAndNewlines
deviceLanguage = try String(contentsOf: path, encoding: .utf8).trimmingCharacters(in: trimCharacterSet)
app.launchArguments += ["-AppleLanguages", "(\(deviceLanguage))"]
} catch {
- print("Couldn't detect/set language...")
+ NSLog("Couldn't detect/set language...")
}
}
class func setLocale(_ app: XCUIApplication) {
guard let cacheDirectory = self.cacheDirectory else {
- print("CacheDirectory is not set - probably running on a physical device?")
+ NSLog("CacheDirectory is not set - probably running on a physical device?")
return
}
-
+
let path = cacheDirectory.appendingPathComponent("locale.txt")
do {
let trimCharacterSet = CharacterSet.whitespacesAndNewlines
locale = try String(contentsOf: path, encoding: .utf8).trimmingCharacters(in: trimCharacterSet)
} catch {
- print("Couldn't detect/set locale...")
+ NSLog("Couldn't detect/set locale...")
}
-
+
if locale.isEmpty && !deviceLanguage.isEmpty {
locale = Locale(identifier: deviceLanguage).identifier
}
-
+
if !locale.isEmpty {
app.launchArguments += ["-AppleLocale", "\"\(locale)\""]
}
}
class func setLaunchArguments(_ app: XCUIApplication) {
guard let cacheDirectory = self.cacheDirectory else {
- print("CacheDirectory is not set - probably running on a physical device?")
+ NSLog("CacheDirectory is not set - probably running on a physical device?")
return
}
-
+
let path = cacheDirectory.appendingPathComponent("snapshot-launch_arguments.txt")
app.launchArguments += ["-FASTLANE_SNAPSHOT", "YES", "-ui_testing"]
do {
let launchArguments = try String(contentsOf: path, encoding: String.Encoding.utf8)
@@ -142,59 +142,59 @@
let results = matches.map { result -> String in
(launchArguments as NSString).substring(with: result.range)
}
app.launchArguments += results
} catch {
- print("Couldn't detect/set launch_arguments...")
+ NSLog("Couldn't detect/set launch_arguments...")
}
}
open class func snapshot(_ name: String, timeWaitingForIdle timeout: TimeInterval = 20) {
if timeout > 0 {
waitForLoadingIndicatorToDisappear(within: timeout)
}
- print("snapshot: \(name)") // more information about this, check out https://docs.fastlane.tools/actions/snapshot/#how-does-it-work
+ NSLog("snapshot: \(name)") // more information about this, check out https://docs.fastlane.tools/actions/snapshot/#how-does-it-work
if Snapshot.waitForAnimations {
sleep(1) // Waiting for the animation to be finished (kind of)
}
#if os(OSX)
guard let app = self.app else {
- print("XCUIApplication is not set. Please call setupSnapshot(app) before snapshot().")
+ NSLog("XCUIApplication is not set. Please call setupSnapshot(app) before snapshot().")
return
}
app.typeKey(XCUIKeyboardKeySecondaryFn, modifierFlags: [])
#else
-
+
guard let app = self.app else {
- print("XCUIApplication is not set. Please call setupSnapshot(app) before snapshot().")
+ NSLog("XCUIApplication is not set. Please call setupSnapshot(app) before snapshot().")
return
}
-
+
let window = app.windows.firstMatch
let screenshot = window.screenshot()
guard let simulator = ProcessInfo().environment["SIMULATOR_DEVICE_NAME"], let screenshotsDir = screenshotsDirectory else { return }
let path = screenshotsDir.appendingPathComponent("\(simulator)-\(name).png")
do {
try screenshot.pngRepresentation.write(to: path)
} catch let error {
- print("Problem writing screenshot: \(name) to \(path)")
- print(error)
+ NSLog("Problem writing screenshot: \(name) to \(path)")
+ NSLog(error.localizedDescription)
}
#endif
}
class func waitForLoadingIndicatorToDisappear(within timeout: TimeInterval) {
#if os(tvOS)
return
#endif
guard let app = self.app else {
- print("XCUIApplication is not set. Please call setupSnapshot(app) before snapshot().")
+ NSLog("XCUIApplication is not set. Please call setupSnapshot(app) before snapshot().")
return
}
let networkLoadingIndicator = app.otherElements.deviceStatusBars.networkLoadingIndicators.element
let networkLoadingIndicatorDisappeared = XCTNSPredicateExpectation(predicate: NSPredicate(format: "exists == false"), object: networkLoadingIndicator)
@@ -293,6 +293,6 @@
}
}
// Please don't remove the lines below
// They are used to detect outdated configuration files
-// SnapshotHelperVersion [1.15]
+// SnapshotHelperVersion [1.16]