lib/scan/detect_values.rb in scan-0.3.1 vs lib/scan/detect_values.rb in scan-0.3.2

- old
+ new

@@ -24,11 +24,10 @@ def self.default_device config = Scan.config if config[:device] # make sure it actually exists - device = config[:device].to_s.strip.tr('()', '') # Remove parenthesis found = FastlaneCore::Simulator.all.find { |d| (d.name + " " + d.ios_version).include? device } if found @@ -37,12 +36,21 @@ else Helper.log.error "Couldn't find simulator '#{config[:device]}' - falling back to default simulator".red end end + sims = FastlaneCore::Simulator.all + xcode_target = Scan.project.build_settings(key: "IPHONEOS_DEPLOYMENT_TARGET") + + # Filter out any simulators that are not the same major version of our deployment target + if xcode_target.to_s.length > 0 + min_target = xcode_target.split(".").first.to_i + sims = sims.select { |s| s.ios_version.to_i >= min_target } + end + # An iPhone 5s is reasonable small and useful for tests - found = FastlaneCore::Simulator.all.find { |d| d.name == "iPhone 5s" } - found ||= FastlaneCore::Simulator.all.first # anything is better than nothing + found = sims.find { |d| d.name == "iPhone 5s" } + found ||= sims.first # anything is better than nothing Scan.device = found raise "No simulators found".red unless Scan.device end