Skip to content

Commit

Permalink
fix odd indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
wuaar1003 committed Dec 12, 2023
1 parent 97632a9 commit 0d8dcdf
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 47 deletions.
18 changes: 9 additions & 9 deletions fastlane_core/lib/fastlane_core/device_manager.rb
Expand Up @@ -13,15 +13,15 @@ def all(requested_os_type = "")

def runtime_build_os_versions
@runtime_build_os_versions ||= begin
output, status = Open3.capture2('xcrun simctl list runtimes -j')
raise status unless status.success?
json = JSON.parse(output)
json['runtimes'].map { |h| [h['buildversion'], h['version']] }.to_h
rescue StandardError => e
UI.error(e)
UI.error('xcrun simctl CLI broken; cun `xcrun simctl list runtimes` and make sure it works')
UI.user_error!('xcrun simctl not working')
end
output, status = Open3.capture2('xcrun simctl list runtimes -j')
raise status unless status.success?
json = JSON.parse(output)
json['runtimes'].map { |h| [h['buildversion'], h['version']] }.to_h
rescue StandardError => e
UI.error(e)
UI.error('xcrun simctl CLI broken; cun `xcrun simctl list runtimes` and make sure it works')
UI.user_error!('xcrun simctl not working')
end
end

def simulators(requested_os_type = "")
Expand Down
76 changes: 38 additions & 38 deletions scan/lib/scan/detect_values.rb
Expand Up @@ -112,44 +112,44 @@ def self.filter_simulators(simulators, operator = :greater_than_or_equal, deploy
def self.default_os_version(os_type)
@os_versions ||= {}
@os_versions[os_type] ||= begin
UI.crash!("Unknown platform: #{os_type}") unless PLATFORMS.key?(os_type)
platform = PLATFORMS[os_type]

_, error, = Open3.capture3('xcrun simctl runtime -h')
unless error.include?('Usage: simctl runtime <operation> <arguments>')
UI.error("xcrun simctl runtime broken, run 'xcrun simctl runtime' and make sure it works")
UI.user_error!("xcrun simctl runtime not working.")
end

# `match list` subcommand added in Xcode 15
if error.include?('match list')

# list SDK version for currently running Xcode
sdks_output, status = Open3.capture2('xcodebuild -showsdks -json')
sdk_version = begin
raise status unless status.success?
JSON.parse(sdks_output).find { |e| e['platform'] == platform[:simulator] }['sdkVersion']
rescue StandardError => e
UI.error(e)
UI.error("xcodebuild CLI broken, please run `xcodebuild` and make sure it works")
UI.user_error!("xcodebuild not working")
end

# Get runtime build from SDK version
runtime_output, status = Open3.capture2('xcrun simctl runtime match list -j')
runtime_build = begin
raise status unless status.success?
JSON.parse(runtime_output).values.find { |elem| elem['platform'] == platform[:name] && elem['sdkVersion'] == sdk_version }['chosenRuntimeBuild']
rescue StandardError => e
UI.error(e)
UI.error("xcrun simctl runtime broken, please verify that `xcrun simctl runtime match list` and `xcrun simctl runtime list` work")
UI.user_error!("xcrun simctl runtime not working")
end

# Get OS version corresponding to build
Gem::Version.new(FastlaneCore::DeviceManager.runtime_build_os_versions[runtime_build])
end
end
UI.crash!("Unknown platform: #{os_type}") unless PLATFORMS.key?(os_type)
platform = PLATFORMS[os_type]

_, error, = Open3.capture3('xcrun simctl runtime -h')
unless error.include?('Usage: simctl runtime <operation> <arguments>')
UI.error("xcrun simctl runtime broken, run 'xcrun simctl runtime' and make sure it works")
UI.user_error!("xcrun simctl runtime not working.")
end

# `match list` subcommand added in Xcode 15
if error.include?('match list')

# list SDK version for currently running Xcode
sdks_output, status = Open3.capture2('xcodebuild -showsdks -json')
sdk_version = begin
raise status unless status.success?
JSON.parse(sdks_output).find { |e| e['platform'] == platform[:simulator] }['sdkVersion']
rescue StandardError => e
UI.error(e)
UI.error("xcodebuild CLI broken, please run `xcodebuild` and make sure it works")
UI.user_error!("xcodebuild not working")
end

# Get runtime build from SDK version
runtime_output, status = Open3.capture2('xcrun simctl runtime match list -j')
runtime_build = begin
raise status unless status.success?
JSON.parse(runtime_output).values.find { |elem| elem['platform'] == platform[:name] && elem['sdkVersion'] == sdk_version }['chosenRuntimeBuild']
rescue StandardError => e
UI.error(e)
UI.error("xcrun simctl runtime broken, please verify that `xcrun simctl runtime match list` and `xcrun simctl runtime list` work")
UI.user_error!("xcrun simctl runtime not working")
end

# Get OS version corresponding to build
Gem::Version.new(FastlaneCore::DeviceManager.runtime_build_os_versions[runtime_build])
end
end
end

def self.clear_cache
Expand Down

0 comments on commit 0d8dcdf

Please sign in to comment.