Skip to content

Commit

Permalink
Merge branch 'release/0.0.11'
Browse files Browse the repository at this point in the history
  • Loading branch information
Blackjacx committed Oct 19, 2021
2 parents 6b75bf9 + 07914c0 commit 30c306e
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 56 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## [Unreleased]

## [0.0.11] - 2021-10-19Z
* [#34](https://github.com/blackjacx/assist/pull/34): Replace mode by dedicated parameters for appearance and devices - [@blackjacx](https://github.com/blackjacx).

## [0.0.10] - 2021-10-05Z
* [#33](https://github.com/blackjacx/assist/pull/33): Properly wait while Simulator boots - [@blackjacx](https://github.com/blackjacx).

Expand Down
16 changes: 8 additions & 8 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// swift-tools-version:5.3
// swift-tools-version:5.4
import PackageDescription

let package = Package(
name: "Assist",
platforms: [
.macOS(.v10_15),
.macOS(.v11),
// .iOS(.v11),
// .watchOS(.v5),
// .tvOS(.v11)
Expand All @@ -19,9 +19,9 @@ let package = Package(
.package(name: "Engine", url: "https://github.com/blackjacx/Engine", .branch("develop")),
// .package(name: "ASCKit", path: "../ASCKit"),
// .package(name: "Engine", path: "../Engine"),
.package(url: "https://github.com/apple/swift-argument-parser", from: "0.4.1"),
.package(url: "https://github.com/vapor/jwt-kit.git", from: "4.1.0"),
.package(url: "https://github.com/kareman/SwiftShell", from: "5.1.0")
.package(url: "https://github.com/apple/swift-argument-parser", .upToNextMajor(from: "1.0.0")),
.package(url: "https://github.com/vapor/jwt-kit.git", .upToNextMajor(from: "4.1.0")),
.package(url: "https://github.com/kareman/SwiftShell", .upToNextMajor(from: "5.1.0"))
],
targets: [
.target(
Expand All @@ -33,7 +33,7 @@ let package = Package(
]
),

.target(
.executableTarget(
name: "ASC",
dependencies: [
.product(name: "ArgumentParser", package: "swift-argument-parser"),
Expand All @@ -46,7 +46,7 @@ let package = Package(
),


.target(
.executableTarget(
name: "Push",
dependencies: [
"Core",
Expand All @@ -59,7 +59,7 @@ let package = Package(
),


.target(
.executableTarget(
name: "Snap",
dependencies: [
"Core",
Expand Down
78 changes: 68 additions & 10 deletions Sources/Core/Simulator/Simctl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ public extension Simctl {
var deviceIDs: [String] = []

try deviceTypes.forEach { (deviceType) in
guard let deviceID = try devicesForRuntime(runtime).first(where: { $0.name == deviceType.rawValue }) else {
guard let deviceID = try devicesForRuntime(runtime).first(where: { $0.name == deviceType.simCtlValue }) else {
// Create device if it is not yet available
let deviceID = try createDevice(name: deviceType.rawValue, id: deviceType.rawValue, runtime: runtime)
let deviceID = try createDevice(name: deviceType.simCtlValue, id: deviceType.simCtlValue, runtime: runtime)
deviceIDs.append(deviceID)
return
}
Expand Down Expand Up @@ -173,16 +173,73 @@ public extension Simctl {
case light
case dark

public var name: String { "\(self)" }
public var parameterName: String { rawValue }
}

enum DeviceType: String, CaseIterable {
case iPhoneSE = "iPhone SE (2nd generation)"
case iPhone12 = "iPhone 12"
case iPhone12Pro = "iPhone 12 Pro"
case iPhone12ProMax = "iPhone 12 Pro Max"
// "Apple TV 4K (2nd generation)"
// "Apple TV 4K (at 1080p) (2nd generation)"
// "Apple TV 4K (at 1080p)"
// "Apple TV 4K"
// "Apple TV"
// "Apple Watch SE - 40mm"
// "Apple Watch SE - 44mm"
// "Apple Watch Series 3 - 38mm"
// "Apple Watch Series 3 - 42mm"
// "Apple Watch Series 4 - 40mm"
// "Apple Watch Series 4 - 44mm"
// "Apple Watch Series 5 - 40mm"
// "Apple Watch Series 5 - 44mm"
// "Apple Watch Series 6 - 40mm"
// "Apple Watch Series 6 - 44mm"
// "iPad (5th generation)"
// "iPad (6th generation)"
// "iPad (7th generation)"
// "iPad (8th generation)"
// "iPad Air (3rd generation)"
// "iPad Air (4th generation)"
// "iPad Air 2"
// "iPad Air"
// "iPad Pro (10.5-inch)"
// "iPad Pro (11-inch) (1st generation)"
// "iPad Pro (11-inch) (2nd generation)"
// "iPad Pro (11-inch) (3rd generation)"
// "iPad Pro (12.9-inch) (1st generation)"
// "iPad Pro (12.9-inch) (2nd generation)"
// "iPad Pro (12.9-inch) (3rd generation)"
// "iPad Pro (12.9-inch) (4th generation)"
// "iPad Pro (12.9-inch) (5th generation)"
// "iPad Pro (9.7-inch)"
// "iPad mini (5th generation)"
// "iPad mini 2"
// "iPad mini 3"
// "iPad mini 4"
// "iPhone 8 Plus"
// "iPhone 8"

public var name: String { "\(self)" }
enum DeviceType: String, CaseIterable {
case iPhoneSE
case iPhone11
case iPhone11Pro
case iPhone11ProMax
case iPhone12Mini
case iPhone12
case iPhone12Pro
case iPhone12ProMax

public var parameterName: String { rawValue }

public var simCtlValue: String {
switch self {
case .iPhoneSE: return "iPhone SE (2nd generation)"
case .iPhone11: return "iPhone 11"
case .iPhone11Pro: return "iPhone 11 Pro"
case .iPhone11ProMax: return "iPhone 11 Pro Max"
case .iPhone12Mini: return "iPhone 12 mini"
case .iPhone12: return "iPhone 12"
case .iPhone12Pro: return "iPhone 12 Pro"
case .iPhone12ProMax: return "iPhone 12 Pro Max"
}
}
}

/// This enum represents only the latest ios versions from a major version. Omit the platform parameter to use the
Expand All @@ -191,8 +248,9 @@ public extension Simctl {
case ios12_4 = "iOS 12.4"
case ios13_7 = "iOS 13.6"
case ios14_5 = "iOS 14.5"
case ios15_0 = "iOS 15.0"

public var name: String { "\(self)" }
public var parameterName: String { "\(self)" }
}

enum DataNetwork: String {
Expand Down
48 changes: 10 additions & 38 deletions Sources/Snap/commands/sub/Run.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,11 @@ extension Snap {
@Option(name: [.short, .customLong("scheme")], help: "A scheme to run the screenshot tests on. Can be specified multiple times to generate screenshots for multiple schemes.")
var schemes: [String]

@Option(help: "The mode the tool should run in.")
var mode: ExecutionMode
@Option(parsing: .upToNextOption, help: "The appearances the screenshots should be made for, e.g. --appearances \(Simctl.Style.allCases.map({"\"\($0.parameterName)\""}).joined(separator: " "))")
var appearances: [Simctl.Style] = [.light]

@Option(parsing: .upToNextOption, help: "Devices you want to generate screenshots for, e.g. --devices \(Simctl.DeviceType.allCases.map({"\"\($0.parameterName)\""}).joined(separator: " "))")
var devices: [Simctl.DeviceType] = [.iPhone12Pro]

@Option(help: "The destination directory where the screenshots and the zip archive should be stored.")
var destinationDir: String?
Expand Down Expand Up @@ -102,9 +105,8 @@ extension Snap {

let configMessage = """
Using the following config:
mode: \(mode.name)
styles: \(mode.styles.map { $0.name })
devices: \(mode.devices.map { $0.name })
styles: \(appearances.map { $0.parameterName })
devices: \(devices.map { $0.parameterName })
platform: \(platform)
schemes: \(schemes)
destination: \(outURL.path.appendPathComponent(zipFileName))
Expand All @@ -118,7 +120,7 @@ extension Snap {
Logger.shared.info("Runtime found \(runtime)")

Logger.shared.info("Find IDs of preferred device IDs")
let deviceIds = try Simctl.deviceIdsFor(deviceTypes: mode.devices, runtime: runtime)
let deviceIds = try Simctl.deviceIdsFor(deviceTypes: devices, runtime: runtime)
Logger.shared.info("Device IDs Found: \(deviceIds)")

Logger.shared.info("Building all requested schemes for testing")
Expand All @@ -128,7 +130,7 @@ extension Snap {
deviceIds: deviceIds)

Logger.shared.info("Taking screenshots for all requested configs")
try Simctl.snap(styles: mode.styles,
try Simctl.snap(styles: appearances,
workspace: workspace,
schemes: schemes,
deviceIds: deviceIds,
Expand All @@ -150,35 +152,5 @@ extension Snap {
}

extension Simctl.Style: ExpressibleByArgument {}
extension Simctl.DeviceType: ExpressibleByArgument {}
extension Simctl.Platform: ExpressibleByArgument {}

extension Snap.Run {

enum ExecutionMode: String, ExpressibleByArgument, CaseIterable {
case fast
case full

var defaultValueDescription: String {
switch self {
case .fast: return "Generates screenshots on a single device / language / appearance only."
case .full: return "Generates all the combinations of screenshots. Takes significantly longer."
}
}

var styles: [Simctl.Style] {
switch self {
case .fast: return [.light]
case .full: return [.light, .dark]
}
}

var devices: [Simctl.DeviceType] {
switch self {
case .fast: return [.iPhone12]
case .full: return [.iPhoneSE, .iPhone12Pro, .iPhone12ProMax]
}
}

var name: String { "\(self)" }
}
}

0 comments on commit 30c306e

Please sign in to comment.