devicekit / DeviceKit

DeviceKit is a value-type replacement of UIDevice.
MIT License
4.42k stars 428 forks source link

Crashing calling Device.current.safeDescription #278

Open bladebunny opened 3 years ago

bladebunny commented 3 years ago

Internally Device.identifier is failling and Device.current returns an invalid pointer. Device.current.safeDescription then crashes because it doesn't handle the failure or throw. It seem like this should really throw or return an optional.

This occurred on an iPhone 11 Pro sim. Tried with both v.4.0.0 and latest (4.3.0). We use in a lib that we distribute internally. And I'm looking at an issue where another group wraps our lib in their own lib within their app. So the dependency graph looks like: App -> theirLib -> ourLib -> DeviceKit

Seeing if i can work out a solution with a local copy. Thank you!

bladebunny commented 3 years ago

Some additional follow up: identifier is returning "x86_64". ProcessInfo().environment["SIMULATOR_MODEL_IDENTIFIER"] finds "iPhone12,3" but the result of calling back into mapToDevice, even though its a valid case, is returning "invalid". And the call to simulator(mapping) is also invalid. So, for whatever reason, iPhone11Pro comes back as invalid. Seems like the recursive look up on the enum is failing for some reason.