Closed Bunn closed 5 years ago
you need to cast 'let availability = deviceJson["isAvailable"] as? Bool' otherwise it fails on my Mac with Xcode 10.1 (10B61)
@RomainQuidet weird, I'm using Xcode Version 10.1 (10B61) and it works fine
When I list the devices xcrun simctl list -j devices
I see that there's still a String availability
in there, so it is just ignoring the isAvailable
and using the previous method of checking availability.
"availability" : "(available)",
"state" : "Booted",
"isAvailable" : true,
"name" : "iPhone SE",
"udid" : "E5396320-D52B-4061-913D-CAAFB7A938D0",
"availabilityError" : ""
which then uses this enum
enum Availability: String {
case available = "(available)"
case unavailable = "(unavailable, runtime profile not found)"
}
I think that using the new isAvailable
could be better, but would break backwards compatibility.
If you run this command on your terminal, is the output different?
Thanks for the PR and sorry for my late reply....
Codable does seem like a better way.
My other thought is to use FBSimulatorControl as a dependency in place of the json parsing part. I had some attempts in the direct-simctl
branch but since my current work doesn't involve iOS development so that didn't go too far.
Also I'm looking for some collaborators of this project. If anyone's interested please let me know.
@RomainQuidet weird, I'm using Xcode Version 10.1 (10B61) and it works fine
When I list the devices
xcrun simctl list -j devices
I see that there's still a Stringavailability
in there, so it is just ignoring theisAvailable
and using the previous method of checking availability."availability" : "(available)", "state" : "Booted", "isAvailable" : true, "name" : "iPhone SE", "udid" : "E5396320-D52B-4061-913D-CAAFB7A938D0", "availabilityError" : ""
which then uses this enum
enum Availability: String { case available = "(available)" case unavailable = "(unavailable, runtime profile not found)" }
I think that using the new
isAvailable
could be better, but would break backwards compatibility.If you run this command on your terminal, is the output different?
My bad I moved to isAvailable key with PR #44 so I mixed up the parsing. Your PR is working great.
Codable does seem like a better way.
My other thought is to use FBSimulatorControl as a dependency in place of the json parsing part. I had some attempts in the
direct-simctl
branch but since my current work doesn't involve iOS development so that didn't go too far.Also I'm looking for some collaborators of this project. If anyone's interested please let me know.
@luosheng I'm interested, although I have a busy schedule and have no idea how much of my time I'd be able to invest here, this is an app that I use daily, so I'd be happy to help maintain it :)
On Xcode 10.1 there’s a new property on the device json which is not a String: "isAvailable" : true,
This was causing the parser to fail due the [[String:String]] casting.
I changed it to [[String:AnyObject]] and added String casts on the if let.
Ideally this would be solved using codable, but it would require a bigger refactor. I might give it a shot later but I wanted a quick fix to keep using this ASAP :)