Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Swift 2.3] Fix crash for looking up sim id on real device #61

Merged
merged 5 commits into from
Jan 5, 2017
Merged

[Swift 2.3] Fix crash for looking up sim id on real device #61

merged 5 commits into from
Jan 5, 2017

Conversation

kdawgwilk
Copy link
Contributor

This fixes a crash when trying to lookup a simulator identifier on a real device. Fixes Issue #60

@kdawgwilk kdawgwilk changed the title Fix crash for looking up sim id on real device [Swift 2.3] Fix crash for looking up sim id on real device Jan 5, 2017
@kdawgwilk
Copy link
Contributor Author

Hold off on this...I thought it was the force unwrap causing the crash but it appears to be the getenv() call that is crashing

@kdawgwilk
Copy link
Contributor Author

Alright this is ready to go. I found a better API to get the ENV var for the simulator that won't crash if it doesn't exist. and I give a default "Unknown" value as the identifier because I tried the identifier passed in but it caused and infinite recursion :(

@dennisweissmann
Copy link
Collaborator

Hi, this one looks just as good as the Swift 3 one, however it doesn't build because line length is now 162 instead of 160 (this is an issue coming from our swiftlint rules. 2 possible fixes: change the rule in .swiftlint.yml or split the statement over multiple lines (I'd prefer the latter). Other than that: 💯🎉🙏 :)

case "i386", "x86_64": return Simulator(mapIdentifierToDevice(String(UTF8String: getenv("SIMULATOR_MODEL_IDENTIFIER"))!))
case "i386", "x86_64": return Simulator(mapIdentifierToDevice(
NSProcessInfo().environment["SIMULATOR_MODEL_IDENTIFIER"] ?? "iOS"
))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks weird here in the diff but it should look alright in Xcode

@kdawgwilk
Copy link
Contributor Author

Looks like CI flaked out here as well?

@dennisweissmann
Copy link
Collaborator

Perfect, thank you so much! :)

@dennisweissmann dennisweissmann merged commit 49829ba into devicekit:swift-2.3-unsupported Jan 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants