Open dnicolson opened 1 year ago
Nice catch, thank you :)
Another approach could be to filter out undecodable runtimes in the RuntimeList class, this actually resulted in more code though.
I prefer that approach. it doesn't have to be a lot of code, actually, it's less code.
Remove all the installed runtimes with the state unusable
, before looping over them, then you can then force-unwrap build
, version
, and platformIdentifier
(and remove the unknown enum case).
I would also add a note at the end with how many unknown runtimes were found, with a suggestion to run xcrun simctl runtime list -j
for more info.
Disclaimer: I contributed the runtimes feature but I'm not part of the team, so you might want to wait for their opinion/review.
The amount of unknown runtimes is indicated by how many "Unknown" runtimes are listed, it should be comparable to what is in Xcode. It's not ideal that there is a 0
though, but further hacks wouldn't have been nice.
The original approach seemed to require using a custom decoder and possibly filtering out the items unable to be decoded afterward. Or do you mean keeping the optional keys so that the decoding doesn't fail?
Or do you mean keeping the optional keys so that the decoding doesn't fail?
yeah, what i meant is removing the
-- Unknown --
Unknown 0 (Downloaded)
and replacing it at the end with (if more than 0):
Note: Found 1 unknown downloaded runtime(s). For more info run `xcrun simctl runtime list -j`.
you just have to add let unusableCount = installed.removeAll { $0.state == "Unusable" }.count
before looping over the installed
array, and then you can force-unwrap the newly optional values.
I've made those changes, thanks for the input!
This pull request prevents the following error when running
xcodes runtimes
when an "Unknown Platform Simulator" is installed:If one accidentally runs
xcrun simctl runtime add
with an incompatible pre-iOS 16 Simulator runtime:The following error will be displayed:
The problem is that it's not immediately obvious that Xcode has still installed the runtime, but with a missing signature state:![PixelSnap 2023-01-04 at 07 50 16@2x](https://user-images.githubusercontent.com/2276355/210500459-f0f4d6e0-c2b4-4e7d-9d1c-f65d960c129f.png)
And when xcodes runs
xcrun simctl runtime list -j
, there is nobuild
key resulting in the error:This change results in the following
xcodes runtimes
output:Another approach could be to filter out undecodable runtimes in the
RuntimeList
class, this actually resulted in more code though.