Skip to content

Commit 6521756

Browse files
ah I think that the tvOS one is an actual error
1 parent b57440b commit 6521756

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

Sources/BuildTool/BuildTool.swift

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ struct SimctlOutput: Codable {
6161

6262
enum Error: Swift.Error {
6363
case terminatedWithExitCode(Int32)
64+
case simulatorLookupFailed(message: String)
6465
}
6566

6667
// 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?
@@ -106,12 +107,15 @@ struct BuildTool: ParsableCommand {
106107

107108
let runtimeIdentifier = "com.apple.CoreSimulator.SimRuntime.\(destinationPredicate.runtime)"
108109
let deviceTypeIdentifier = "com.apple.CoreSimulator.SimDeviceType.\(destinationPredicate.deviceType)"
109-
guard let matchingDevices = simctlOutput.devices[runtimeIdentifier]?.filter({ $0.deviceTypeIdentifier == deviceTypeIdentifier }) else {
110-
fatalError("Couldn’t find a simulator with runtime \(runtimeIdentifier) and device type \(deviceTypeIdentifier); available devices are \(simctlOutput.devices)")
110+
111+
let matchingDevices = (simctlOutput.devices[runtimeIdentifier] ?? []).filter({ $0.deviceTypeIdentifier == deviceTypeIdentifier })
112+
113+
guard matchingDevices.count > 0 else {
114+
throw Error.simulatorLookupFailed(message: "Couldn’t find a simulator with runtime \(runtimeIdentifier) and device type \(deviceTypeIdentifier); available devices are \(simctlOutput.devices)")
111115
}
112116

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

117121
return matchingDevices[0].udid

0 commit comments

Comments
 (0)