Class: Snapshot::DependencyChecker

Inherits:
Object
  • Object
show all
Defined in:
snapshot/lib/snapshot/dependency_checker.rb

Class Method Summary collapse

Class Method Details

.check_dependenciesObject



7
8
9
10
11
12
13
# File 'snapshot/lib/snapshot/dependency_checker.rb', line 7

def self.check_dependencies
  return if FastlaneCore::Helper.test?
  return unless FastlaneCore::Helper.mac?

  self.check_xcode_select
  self.check_simctl
end

.check_simctlObject



56
57
58
59
60
61
62
63
64
65
66
67
# File 'snapshot/lib/snapshot/dependency_checker.rb', line 56

def self.check_simctl
  simctl_available = nil
  begin
    simctl_available = `xcrun simctl`.include?("openurl")
  rescue
    simctl_available = true
  end

  unless simctl_available
    FastlaneCore::UI.user_error!("Could not find `xcrun simctl`. Make sure you have the latest version of Xcode and macOS installed.")
  end
end

.check_simulatorsObject



43
44
45
46
47
48
49
50
51
52
53
54
# File 'snapshot/lib/snapshot/dependency_checker.rb', line 43

def self.check_simulators
  FastlaneCore::UI.verbose("Found #{FastlaneCore::Simulator.all.count} simulators.")
  if FastlaneCore::Simulator.all.count == 0
    FastlaneCore::UI.error('#############################################################')
    FastlaneCore::UI.error("# You have to add new simulators using Xcode")
    FastlaneCore::UI.error("# You can let snapshot create new simulators: 'fastlane snapshot reset_simulators'")
    FastlaneCore::UI.error("# Manually: Xcode => Window => Devices")
    FastlaneCore::UI.error("# Please run `instruments -s` to verify your xcode path")
    FastlaneCore::UI.error('#############################################################')
    FastlaneCore::UI.user_error!("Create the new simulators and run this script again")
  end
end

.check_xcode_selectObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'snapshot/lib/snapshot/dependency_checker.rb', line 15

def self.check_xcode_select
  xcode_available = nil
  begin
    xcode_available = `xcode-select -v`.include?("xcode-select version")
  rescue
    xcode_available = true
  end

  unless xcode_available
    FastlaneCore::UI.error('#############################################################')
    FastlaneCore::UI.error("# You have to install Xcode command line tools to use snapshot")
    FastlaneCore::UI.error("# Install the latest version of Xcode from the AppStore")
    FastlaneCore::UI.error("# Run xcode-select --install to install the developer tools")
    FastlaneCore::UI.error('#############################################################')
    FastlaneCore::UI.user_error!("Run 'xcode-select --install' and start snapshot again")
  end

  if Snapshot::LatestOsVersion.ios_version.to_f < 9 # to_f is bad, but should be good enough
    FastlaneCore::UI.error('#############################################################')
    FastlaneCore::UI.error("# Your xcode-select Xcode version is below 7.0")
    FastlaneCore::UI.error("# To use snapshot 1.0 and above you need at least iOS 9")
    FastlaneCore::UI.error("# Set the path to the Xcode version that supports UI Tests")
    FastlaneCore::UI.error("# or downgrade to versions older than snapshot 1.0")
    FastlaneCore::UI.error('#############################################################')
    FastlaneCore::UI.user_error!("Run 'sudo xcode-select -s /Applications/Xcode-beta.app'")
  end
end