500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
|
# File 'lib/run_loop/core.rb', line 500
def self.udid_and_bundle_for_launcher(device_target, options, sim_control=RunLoop::SimControl.new)
xcode = sim_control.xcode
bundle_dir_or_bundle_id = options[:app] || RunLoop::Environment.bundle_id || RunLoop::Environment.path_to_app_bundle
unless bundle_dir_or_bundle_id
raise 'key :app or environment variable APP_BUNDLE_PATH, BUNDLE_ID or APP must be specified as path to app bundle (simulator) or bundle id (device)'
end
udid = nil
if xcode.version_gte_51?
if device_target.nil? || device_target.empty? || device_target == 'simulator'
device_target = self.default_simulator(xcode)
end
udid = device_target
unless self.simulator_target?(options)
bundle_dir_or_bundle_id = options[:bundle_id] if options[:bundle_id]
end
else
if device_target == 'simulator'
unless File.exist?(bundle_dir_or_bundle_id)
raise "Unable to find app in directory #{bundle_dir_or_bundle_id} when trying to launch simulator"
end
device = options[:device] || :iphone
device = device && device.to_sym
plistbuddy='/usr/libexec/PlistBuddy'
plistfile="#{bundle_dir_or_bundle_id}/Info.plist"
if device == :iphone
uidevicefamily=1
else
uidevicefamily=2
end
system("#{plistbuddy} -c 'Delete :UIDeviceFamily' '#{plistfile}'")
system("#{plistbuddy} -c 'Add :UIDeviceFamily array' '#{plistfile}'")
system("#{plistbuddy} -c 'Add :UIDeviceFamily:0 integer #{uidevicefamily}' '#{plistfile}'")
else
udid = device_target
bundle_dir_or_bundle_id = options[:bundle_id] if options[:bundle_id]
end
end
return udid, bundle_dir_or_bundle_id
end
|