Skip to content

Commit

Permalink
ah I think that the tvOS one is an actual error
Browse files Browse the repository at this point in the history
  • Loading branch information
lawrence-forooghian committed Aug 2, 2024
1 parent b57440b commit 6521756
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions Sources/BuildTool/BuildTool.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ struct SimctlOutput: Codable {

enum Error: Swift.Error {
case terminatedWithExitCode(Int32)
case simulatorLookupFailed(message: String)
}

// TODO: Is there a better way to make sure that this script has access to macOS APIs that are more recent than the package’s deployment target?
Expand Down Expand Up @@ -106,12 +107,15 @@ struct BuildTool: ParsableCommand {

let runtimeIdentifier = "com.apple.CoreSimulator.SimRuntime.\(destinationPredicate.runtime)"
let deviceTypeIdentifier = "com.apple.CoreSimulator.SimDeviceType.\(destinationPredicate.deviceType)"
guard let matchingDevices = simctlOutput.devices[runtimeIdentifier]?.filter({ $0.deviceTypeIdentifier == deviceTypeIdentifier }) else {
fatalError("Couldn’t find a simulator with runtime \(runtimeIdentifier) and device type \(deviceTypeIdentifier); available devices are \(simctlOutput.devices)")

let matchingDevices = (simctlOutput.devices[runtimeIdentifier] ?? []).filter({ $0.deviceTypeIdentifier == deviceTypeIdentifier })

guard matchingDevices.count > 0 else {
throw Error.simulatorLookupFailed(message: "Couldn’t find a simulator with runtime \(runtimeIdentifier) and device type \(deviceTypeIdentifier); available devices are \(simctlOutput.devices)")
}

if matchingDevices.count > 1 {
fatalError("Found multiple simulators with runtime \(runtimeIdentifier) and device type \(deviceTypeIdentifier); matching devices are \(matchingDevices)")
guard matchingDevices.count == 1 else {
throw Error.simulatorLookupFailed(message: "Found multiple simulators with runtime \(runtimeIdentifier) and device type \(deviceTypeIdentifier); matching devices are \(matchingDevices)")
}

return matchingDevices[0].udid
Expand Down

0 comments on commit 6521756

Please sign in to comment.