From 5e8f8ffae2acdb8c8a159a494b5bf589580646aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eloy=20Dur=C3=A1n?= Date: Thu, 11 Dec 2014 20:26:21 +0100 Subject: [PATCH] [WatchKit] Be sure to find right extension and fail if there is none. --- lib/motion/project/template/ios.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/motion/project/template/ios.rb b/lib/motion/project/template/ios.rb index 8fde1d2d..0a7aadb2 100644 --- a/lib/motion/project/template/ios.rb +++ b/lib/motion/project/template/ios.rb @@ -79,6 +79,15 @@ end namespace :watch do desc "Run the Watch application on the simulator" task :simulator do + watch_extension = App.config.targets.find do |target| + File.exist?(File.join(target.path, 'watch_app')) + end + unless watch_extension + App.fail 'You can only use this task with a WatchKit application ' \ + 'configured. To configure one use ' \ + '`app.target "path/to/MyWatchApp", :extension`.' + end + if ENV['type'] && ENV['type'].downcase == 'notification' && ENV['payload'].nil? App.fail 'The `payload=path/to/payload.json` option is required with `type=notification`.' end @@ -86,8 +95,7 @@ namespace :watch do unless ENV["skip_build"] Rake::Task["build:simulator"].invoke end - # TODO need a way to identify a watch extension from other extensions - watch_extension = App.config.targets.first + app = App.config.app_bundle('iPhoneSimulator') sim = File.join(App.config.bindir, 'watch-sim')