Module: Platform::IOS::Simulator
Instance Method Summary collapse
- #build_ios_app(settings) ⇒ Object
- #close_and_clean_simulator ⇒ Object
- #remove_sim_temp_files ⇒ Object
- #setup_for_sauce(settings) ⇒ Object
- #start_simulator(settings = nil) ⇒ Object
- #terminate_simulator ⇒ Object
Methods included from OS
Instance Method Details
#build_ios_app(settings) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/mobmanager/mobile/platform/ios/simulator.rb', line 23 def build_ios_app(settings) puts 'Building ios app with xcodebuild tool...' puts 'MobTest: Building ios app with xcodebuild tool...' #TODO - Add to PATH? puts "ENV['IOS_DERIVED_DATA_PATH'] #{ENV['IOS_DERIVED_DATA_PATH']}" fail("MobTest: Failed to determine app_path. Please check your ios.yml settings") if settings[:app_path].nil? app = settings[:app_path].split('/').select{|element| element.include?'.app'}.first system "xcodebuild -workspace #{settings[:workspace_path]} -scheme \"#{app.gsub('.app', '')}\" -configuration Debug -sdk \"#{settings['sim_sdk']}\" -derivedDataPath \"~/\"" end |
#close_and_clean_simulator ⇒ Object
53 54 55 56 |
# File 'lib/mobmanager/mobile/platform/ios/simulator.rb', line 53 def close_and_clean_simulator terminate_simulator remove_sim_temp_files end |
#remove_sim_temp_files ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/mobmanager/mobile/platform/ios/simulator.rb', line 58 def remove_sim_temp_files if mac? #remove ios related files from /private/temp/ path = '/private/tmp' files = Dir["#{path}/**"] files.each do |file| if File.directory?(file) FileUtils.remove_dir(file) if ((file.include? 'com.apple.') || (file.include? 'appium-instruments')) end end else # TODO - research in Windows OS end end |
#setup_for_sauce(settings) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/mobmanager/mobile/platform/ios/simulator.rb', line 33 def setup_for_sauce(settings) sauce_user = %x[echo $SAUCE_USER].strip sauce_key = %x[echo $SAUCE_KEY].strip app_path = settings[:app_path] zipped_app_path = app_path.gsub('.app','.zip') app = app_path.split('/').select{|item| item.include?('.app')}.first.gsub('.app','') puts 'MobTest: Connecting to sauce server...' system "curl https://#{sauce_user}:#{sauce_key}@saucelabs.com/rest/v1/users/#{sauce_user}" puts 'MobTest: Zipping iOS app' system "zip -r #{zipped_app_path} #{app_path}/" zipped_app_path = zipped_app_path.gsub('~',Dir.home) puts 'MobTest: Sending zipped app to sauce storage' system 'curl -u '+"#{sauce_user}:#{sauce_key}"+' -X POST "https://saucelabs.com/rest/v1/storage/'+sauce_user+'/'+app+'.zip?overwrite=true" -H "Content-Type: application/octet-stream" --data-binary @'+zipped_app_path end |
#start_simulator(settings = nil) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/mobmanager/mobile/platform/ios/simulator.rb', line 10 def start_simulator(settings = nil) caps = settings unless settings.nil? caps = YAML.load_file(Dir.pwd + '/features/support/settings/ios.yml') if settings.nil? unless caps[:workspace_path].nil? build_ios_app(caps) end if ENV['TARGET'] == 'sauce' setup_for_sauce(caps) end end |
#terminate_simulator ⇒ Object
48 49 50 51 |
# File 'lib/mobmanager/mobile/platform/ios/simulator.rb', line 48 def terminate_simulator spawn 'killall "iOS Simulator"' spawn 'killall -9 instruments' end |