snapshot/lib/assets/SnapshotHelper.swift in fastlane_hotfix-2.165.1 vs snapshot/lib/assets/SnapshotHelper.swift in fastlane_hotfix-2.187.0

- old
+ new

@@ -178,29 +178,37 @@ let regex = try NSRegularExpression(pattern: "Clone [0-9]+ of ") let range = NSRange(location: 0, length: simulator.count) simulator = regex.stringByReplacingMatches(in: simulator, range: range, withTemplate: "") let path = screenshotsDir.appendingPathComponent("\(simulator)-\(name).png") - try image.pngData()?.write(to: path, options: .atomic) + #if swift(<5.0) + UIImagePNGRepresentation(image)?.write(to: path, options: .atomic) + #else + try image.pngData()?.write(to: path, options: .atomic) + #endif } catch let error { NSLog("Problem writing screenshot: \(name) to \(screenshotsDir)/\(simulator)-\(name).png") NSLog(error.localizedDescription) } #endif } class func fixLandscapeOrientation(image: UIImage) -> UIImage { - if #available(iOS 10.0, *) { - let format = UIGraphicsImageRendererFormat() - format.scale = image.scale - let renderer = UIGraphicsImageRenderer(size: image.size, format: format) - return renderer.image { context in - image.draw(in: CGRect(x: 0, y: 0, width: image.size.width, height: image.size.height)) - } - } else { + #if os(watchOS) return image - } + #else + if #available(iOS 10.0, *) { + let format = UIGraphicsImageRendererFormat() + format.scale = image.scale + let renderer = UIGraphicsImageRenderer(size: image.size, format: format) + return renderer.image { context in + image.draw(in: CGRect(x: 0, y: 0, width: image.size.width, height: image.size.height)) + } + } else { + return image + } + #endif } class func waitForLoadingIndicatorToDisappear(within timeout: TimeInterval) { #if os(tvOS) return @@ -221,11 +229,11 @@ // on OSX config is stored in /Users/<username>/Library // and on iOS/tvOS/WatchOS it's in simulator's home dir #if os(OSX) let homeDir = URL(fileURLWithPath: NSHomeDirectory()) return homeDir.appendingPathComponent(cachePath) - #elseif arch(i386) || arch(x86_64) + #elseif arch(i386) || arch(x86_64) || arch(arm64) guard let simulatorHostHome = ProcessInfo().environment["SIMULATOR_HOST_HOME"] else { throw SnapshotError.cannotFindSimulatorHomeDirectory } let homeDir = URL(fileURLWithPath: simulatorHostHome) return homeDir.appendingPathComponent(cachePath) @@ -296,6 +304,6 @@ } } // Please don't remove the lines below // They are used to detect outdated configuration files -// SnapshotHelperVersion [1.24] +// SnapshotHelperVersion [1.27]