From d18144df9d230c5fb107a900e6a8a48c260cd8ef Mon Sep 17 00:00:00 2001 From: Alexey Alter-Pesotskiy Date: Wed, 26 Jun 2024 10:00:54 +0100 Subject: [PATCH] List runtimes as json --- fastlane/Fastfile | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 54902a3a12b..e62cdc3b6ea 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -765,15 +765,18 @@ lane :rubocop do end lane :install_sim do |options| - runtime_list = sh("xcrun simctl runtime list | grep 'iOS #{options[:ios]}' || true") - if runtime_list.include?('Ready') - UI.important("iOS #{options[:ios]} Runtime already exists") - else + available_simulators = JSON.parse(`xcrun simctl runtime list -j`).select do |_, sim| + sim["version"] == options[:ios] && sim["state"] == "Ready" + end + + if available_simulators.empty? Dir.chdir('..') do sh("echo 'iOS #{options[:ios]} Simulator' | ipsw download xcode --sim") if Dir['*.dmg'].first.nil? sh("./Scripts/install_ios_runtime.sh #{Dir['*.dmg'].first}") UI.success("iOS #{options[:ios]} Runtime successfuly installed") end + else + UI.important("iOS #{options[:ios]} Runtime already exists") end end