Class: Snapshot::DependencyChecker

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

Class Method Summary collapse

Class Method Details

.check_dependenciesObject



3
4
5
6
7
8
9
# File 'lib/snapshot/dependency_checker.rb', line 3

def self.check_dependencies
  self.check_xcode_select
  self.check_simulators
  self.check_xctool
  self.check_for_automation_subfolder
  self.check_simctl
end

.check_for_automation_subfolderObject



48
49
50
51
52
# File 'lib/snapshot/dependency_checker.rb', line 48

def self.check_for_automation_subfolder
  if File.directory?"./Automation" or File.exists?"./Automation"
    raise "Seems like you have an 'Automation' folder in the current directory. You need to delete/rename it!".red
  end
end

.check_simctlObject



54
55
56
57
58
# File 'lib/snapshot/dependency_checker.rb', line 54

def self.check_simctl
  unless `xcrun simctl`.include?"openurl"
    raise "Could not find `xcrun simctl`. Make sure you have the latest version of Xcode and Mac OS installed.".red
  end
end

.check_simulatorsObject



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/snapshot/dependency_checker.rb', line 22

def self.check_simulators
  Helper.log.debug "Found #{Simulators.available_devices.count} simulators."
  if Simulators.available_devices.count < 1
    Helper.log.fatal '#############################################################'
    Helper.log.fatal "# You have to add new simulators using Xcode"
    Helper.log.fatal "# Xcode => Window => Devices"
    Helper.log.fatal "# Please run `instruments -s` to verify your xcode path"
    Helper.log.fatal '#############################################################'
    raise "Create the new simulators and run this script again"
  end
end

.check_xcode_selectObject



11
12
13
14
15
16
17
18
19
20
# File 'lib/snapshot/dependency_checker.rb', line 11

def self.check_xcode_select
  unless `xcode-select -v`.include?"xcode-select version "
    Helper.log.fatal '#############################################################'
    Helper.log.fatal "# You have to install the Xcode commdand line tools to use deliver"
    Helper.log.fatal "# Install the latest version of Xcode from the AppStore"
    Helper.log.fatal "# Run xcode-select --install to install the developer tools"
    Helper.log.fatal '#############################################################'
    raise "Run 'xcode-select --install' and start deliver again"
  end
end

.check_xctoolObject



38
39
40
41
42
43
44
45
46
# File 'lib/snapshot/dependency_checker.rb', line 38

def self.check_xctool
  if not self.xctool_installed?
    Helper.log.error '#############################################################'
    Helper.log.error "# xctool is recommended to build the apps"
    Helper.log.error "# Install it using 'brew install xctool'"
    Helper.log.error "# Falling back to xcode build instead "
    Helper.log.error '#############################################################'
  end
end

.xctool_installed?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/snapshot/dependency_checker.rb', line 34

def self.xctool_installed?
  return `which xctool`.length > 1
end