mirror of
https://github.com/zhigang1992/RubyMotion.git
synced 2026-04-03 22:49:56 +08:00
[WatchKit] Import sim launch task for host app.
This commit is contained in:
@@ -44,7 +44,7 @@ namespace :build do
|
||||
task :simulator do
|
||||
# TODO Try to re-use the env variables used when passing build settings from apps to extensions.
|
||||
rakefile = File.expand_path('../ios-watch-host.rb', __FILE__)
|
||||
sh "rake -I '#{File.join(App.config.motiondir, 'lib')}' -f '#{rakefile}' build:simulator watch_app_name='#{App.config.name}' #{'--trace' if App::VERBOSE}"
|
||||
sh "rake -I '#{File.join(App.config.motiondir, 'lib')}' -f '#{rakefile}' build:simulator simulator watch_app_name='#{App.config.name}' #{'--trace' if App::VERBOSE}"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -74,3 +74,43 @@ namespace :build do
|
||||
App.codesign('iPhoneOS')
|
||||
end
|
||||
end
|
||||
|
||||
desc "Run the simulator"
|
||||
task :simulator do
|
||||
Rake::Task["build:simulator"].invoke
|
||||
app = App.config.app_bundle('iPhoneSimulator')
|
||||
|
||||
if ENV['TMUX']
|
||||
tmux_default_command = `tmux show-options -g default-command`.strip
|
||||
unless tmux_default_command.include?("reattach-to-user-namespace")
|
||||
App.warn(<<END
|
||||
|
||||
It appears you are using tmux without 'reattach-to-user-namespace', the simulator might not work properly. You can either disable tmux or run the following commands:
|
||||
|
||||
$ brew install reattach-to-user-namespace
|
||||
$ echo 'set-option -g default-command "reattach-to-user-namespace -l $SHELL"' >> ~/.tmux.conf
|
||||
|
||||
END
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
family_int = 1 # iPhone
|
||||
target = App.config.sdk_version
|
||||
simulate_device = App.config.device_family_string(nil, family_int, target, nil)
|
||||
|
||||
# Launch the simulator.
|
||||
xcode = App.config.xcode_dir
|
||||
env = "DYLD_FRAMEWORK_PATH=\"#{xcode}/../Frameworks\":\"#{xcode}/../OtherFrameworks\""
|
||||
env << " RM_BUILT_EXECUTABLE=\"#{File.expand_path(App.config.app_bundle_executable('iPhoneSimulator'))}\""
|
||||
env << ' SIM_SPEC_MODE=1' if App.config.spec_mode
|
||||
sim = File.join(App.config.bindir, 'ios/sim')
|
||||
debug = (ENV['debug'] ? 1 : (App.config.spec_mode ? '0' : '2'))
|
||||
app_args = (ENV['args'] or '')
|
||||
App.info 'Simulate', app
|
||||
at_exit { system("stty echo") } if $stdout.tty? # Just in case the simulator launcher crashes and leaves the terminal without echo.
|
||||
Signal.trap(:INT) { } if ENV['debug']
|
||||
system "#{env} #{sim} #{debug} #{family_int} \"#{simulate_device}\" #{target} \"#{xcode}\" \"#{app}\" #{app_args}"
|
||||
App.config.print_crash_message if $?.exitstatus != 0 && !App.config.spec_mode
|
||||
exit($?.exitstatus)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user