def fetch_sims
      device_list = JSON.parse(list(['-j', 'devices']))['devices']
      unless device_list.is_a?(Hash)
        msg = "Expected devices to be of type Hash but instated found #{device_list.class}"
        fail Fourflusher::Informative, msg
      end
      device_list.flat_map do |runtime_str, devices|
        # This format changed with Xcode 10.2.
        if runtime_str.start_with?('com.apple.CoreSimulator.SimRuntime.')
          # Sample string: com.apple.CoreSimulator.SimRuntime.iOS-12-2
          _unused, os_info = runtime_str.split 'com.apple.CoreSimulator.SimRuntime.'
          os_name, os_major_version, os_minor_version = os_info.split '-'
          os_version = "#{os_major_version}.#{os_minor_version}"
        else
          # Sample string: iOS 9.3
          os_name, os_version = runtime_str.split ' '
        end

        devices.map do |device|
          if device['availability'] == '(available)' || device['isAvailable'] == 'YES'
            Simulator.new(device, os_name, os_version)
          end
        end
      end.compact.sort(&:sim_list_compare)
    end
def fetch_sims
      device_list = JSON.parse(list(['-j', 'devices']))['devices']
      unless device_list.is_a?(Hash)
        msg = "Expected devices to be of type Hash but instated found #{device_list.class}"
        fail Fourflusher::Informative, msg
      end
      device_list.flat_map do |runtime_str, devices|
        # This format changed with Xcode 10.2.
        if runtime_str.start_with?('com.apple.CoreSimulator.SimRuntime.')
          # Sample string: com.apple.CoreSimulator.SimRuntime.iOS-12-2
          _unused, os_info = runtime_str.split 'com.apple.CoreSimulator.SimRuntime.'
          os_name, os_major_version, os_minor_version = os_info.split '-'
          os_version = "#{os_major_version}.#{os_minor_version}"
        else
          # Sample string: iOS 9.3
          os_name, os_version = runtime_str.split ' '
        end

        devices.map do |device|
          if device['availability'] == '(available)' || device['isAvailable'] == 'YES'
            Simulator.new(device, os_name, os_version)
          end
        end
      end.compact.sort(&:sim_list_compare)
    end
def fetch_sims device_list = JSON . parse ( list ( [ '-j' , 'devices' ] ) ) [ 'devices' ] unless device_list . is_a? ( Hash ) msg = "Expected devices to be of type Hash but instated found #{device_list.class}" fail Fourflusher :: Informative , msg end device_list . flat_map do | runtime_str , devices | # This format changed with Xcode 10.2. if runtime_str . start_with? ( 'com.apple.CoreSimulator.SimRuntime.' ) # Sample string: com.apple.CoreSimulator.SimRuntime.iOS-12-2 _unused , os_info = runtime_str . split 'com.apple.CoreSimulator.SimRuntime.' os_name , os_major_version , os_minor_version = os_info . split '-' os_version = "#{os_major_version}.#{os_minor_version}" else # Sample string: iOS 9.3 os_name , os_version = runtime_str . split ' ' end devices . map do | device | if device [ 'availability' ] == '(available)' || device [ 'isAvailable' ] == 'YES' Simulator . new ( device , os_name , os_version ) end end end . compact . sort ( :sim_list_compare ) end
Gets the simulators and transforms the simctl json into Simulator objects
Gets the simulators and transforms the simctl json into Simulator objects