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
[frameit] fix device detection that would match less specific devices first #20642
[frameit] fix device detection that would match less specific devices first #20642
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯 Thanks for this!
@@ -51,7 +51,7 @@ def self.detect_device(path, platform) | |||
found_device = nil | |||
filename_device = nil | |||
filename = Pathname.new(path).basename.to_s | |||
Devices.constants.each do |c| | |||
Devices.constants.sort_by(&:length).reverse_each do |c| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a crazy assumption here. But quite safe, IMO. It doesn't rely on business logic or marketing naming standards, but rather "the longer the string, the more specific it will be" and thus matching with partial substrings won't be possible. Quite clever IMO :)
any update? |
Hey @guidev 👋 Thank you for your contribution to fastlane and congrats on getting this pull request merged 🎉 Please let us know if this change requires an immediate release by adding a comment here 👍 |
Congratulations! 🎉 This was released as part of fastlane 2.211.0 🚀 |
Checklist
bundle exec rspec
from the root directory to see all new and existing tests passbundle exec rubocop -a
to ensure the code style is validci/circleci
builds in the "All checks have passed" section of my PR (connect CircleCI to GitHub if not)Motivation and Context
Resolves #20514
Trying to frame a screenshot named
Simulator Screen Shot - iPhone 13 Pro
doesn't work correctly. It0s recognised as aniPhone 13
.Description
One of the checks used to detect the correct device is to see if the filename (
Simulator Screen Shot - iPhone 13 Pro
) contains the device's formatted name (iPhone 13
,iPhone 13 Pro
, etc).Unfortunately the first device to pass all the checks is
iPhone 13
(the device list doesn't seem to be sorted?).Current device list:
I believe the best way to fix this is to check first for the longer device models (check first it it matches
iPhone 13 Pro Max
,iPhone 13 Pro
,iPhone 13
, etc..).Testing Steps