Skip to content

Commit ad77d0d

Browse files
committed
Increased min fastlane version, updated SnapshotHelper
[ci skip]
1 parent 7acd8b6 commit ad77d0d

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

Snapshots/SnapshotHelper.swift

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,12 @@
1515
import Foundation
1616
import XCTest
1717

18-
var deviceLanguage = ""
19-
var locale = ""
20-
18+
@MainActor
2119
func setupSnapshot(_ app: XCUIApplication, waitForAnimations: Bool = true) {
2220
Snapshot.setupSnapshot(app, waitForAnimations: waitForAnimations)
2321
}
2422

23+
@MainActor
2524
func snapshot(_ name: String, waitForLoadingIndicator: Bool) {
2625
if waitForLoadingIndicator {
2726
Snapshot.snapshot(name)
@@ -33,6 +32,7 @@ func snapshot(_ name: String, waitForLoadingIndicator: Bool) {
3332
/// - Parameters:
3433
/// - name: The name of the snapshot
3534
/// - timeout: Amount of seconds to wait until the network loading indicator disappears. Pass `0` if you don't want to wait.
35+
@MainActor
3636
func snapshot(_ name: String, timeWaitingForIdle timeout: TimeInterval = 20) {
3737
Snapshot.snapshot(name, timeWaitingForIdle: timeout)
3838
}
@@ -52,6 +52,7 @@ enum SnapshotError: Error, CustomDebugStringConvertible {
5252
}
5353

5454
@objcMembers
55+
@MainActor
5556
open class Snapshot: NSObject {
5657
static var app: XCUIApplication?
5758
static var waitForAnimations = true
@@ -60,6 +61,9 @@ open class Snapshot: NSObject {
6061
return cacheDirectory?.appendingPathComponent("screenshots", isDirectory: true)
6162
}
6263

64+
static var deviceLanguage = ""
65+
static var currentLocale = ""
66+
6367
open class func setupSnapshot(_ app: XCUIApplication, waitForAnimations: Bool = true) {
6468
Snapshot.app = app
6569
Snapshot.waitForAnimations = waitForAnimations
@@ -102,17 +106,17 @@ open class Snapshot: NSObject {
102106

103107
do {
104108
let trimCharacterSet = CharacterSet.whitespacesAndNewlines
105-
locale = try String(contentsOf: path, encoding: .utf8).trimmingCharacters(in: trimCharacterSet)
109+
currentLocale = try String(contentsOf: path, encoding: .utf8).trimmingCharacters(in: trimCharacterSet)
106110
} catch {
107111
NSLog("Couldn't detect/set locale...")
108112
}
109113

110-
if locale.isEmpty, !deviceLanguage.isEmpty {
111-
locale = Locale(identifier: deviceLanguage).identifier
114+
if currentLocale.isEmpty && !deviceLanguage.isEmpty {
115+
currentLocale = Locale(identifier: deviceLanguage).identifier
112116
}
113117

114-
if !locale.isEmpty {
115-
app.launchArguments += ["-AppleLocale", "\"\(locale)\""]
118+
if !currentLocale.isEmpty {
119+
app.launchArguments += ["-AppleLocale", "\"\(currentLocale)\""]
116120
}
117121
}
118122

@@ -180,7 +184,7 @@ open class Snapshot: NSObject {
180184

181185
let path = screenshotsDir.appendingPathComponent("\(simulator)-\(name).png")
182186
#if swift(<5.0)
183-
UIImagePNGRepresentation(image)?.write(to: path, options: .atomic)
187+
try UIImagePNGRepresentation(image)?.write(to: path, options: .atomic)
184188
#else
185189
try image.pngData()?.write(to: path, options: .atomic)
186190
#endif
@@ -280,6 +284,7 @@ private extension XCUIElementQuery {
280284
return containing(isNetworkLoadingIndicator)
281285
}
282286

287+
@MainActor
283288
var deviceStatusBars: XCUIElementQuery {
284289
guard let app = Snapshot.app else {
285290
fatalError("XCUIApplication is not set. Please call setupSnapshot(app) before snapshot().")
@@ -305,4 +310,4 @@ private extension CGFloat {
305310

306311
// Please don't remove the lines below
307312
// They are used to detect outdated configuration files
308-
// SnapshotHelperVersion [1.28]
313+
// SnapshotHelperVersion [1.30]

fastlane/Fastfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
fastlane_version("2.206.2")
1+
fastlane_version("2.222.0")
22

33
default_platform(:ios)
44

0 commit comments

Comments
 (0)