diff --git a/lib/motion/project/target/extension_target.rb b/lib/motion/project/target/extension_target.rb index c7f913f1..94e04074 100644 --- a/lib/motion/project/target/extension_target.rb +++ b/lib/motion/project/target/extension_target.rb @@ -166,11 +166,13 @@ module Motion; module Project def environment_variables [ - "RM_TARGET_SDK_VERSION=\"#{@config.sdk_version}\"", - "RM_TARGET_DEPLOYMENT_TARGET=\"#{@config.deployment_target}\"", - "RM_TARGET_XCODE_DIR=\"#{@config.xcode_dir}\"", - "RM_TARGET_HOST_APP_PATH=\"#{File.expand_path(@config.project_dir)}\"", - "RM_TARGET_BUILD=\"1\"", + "RM_TARGET_SDK_VERSION='#{@config.sdk_version}'", + "RM_TARGET_DEPLOYMENT_TARGET='#{@config.deployment_target}'", + "RM_TARGET_XCODE_DIR='#{@config.xcode_dir}'", + "RM_TARGET_HOST_APP_NAME='#{@config.name}'", + "RM_TARGET_HOST_APP_IDENTIFIER='#{@config.identifier}'", + "RM_TARGET_HOST_APP_PATH='#{File.expand_path(@config.project_dir)}'", + "RM_TARGET_BUILD='1'", "RM_TARGET_ARCHS='#{@config.archs.inspect}'", ].join(' ') end diff --git a/lib/motion/project/template/ios-watch-extension-builder.rb b/lib/motion/project/template/ios-watch-extension-builder.rb index 63073a9e..dc61c7be 100644 --- a/lib/motion/project/template/ios-watch-extension-builder.rb +++ b/lib/motion/project/template/ios-watch-extension-builder.rb @@ -38,7 +38,6 @@ module Motion; module Project sh "/usr/bin/ibtool --errors --warnings --notices --module #{config.escaped_storyboard_module_name} --minimum-deployment-target #{config.sdk_version} --output-partial-info-plist /tmp/Interface-SBPartialInfo.plist --auto-activate-custom-fonts --output-format human-readable-text --compilation-directory '#{config.app_bundle(platform)}' watch_app/Interface.storyboard" # Create bundle/Info.plist. - config.info_plist['WKCompanionAppBundleIdentifier'] = config.identifier.sub('.watchapp', '') generate_info_plist(config, platform) end diff --git a/lib/motion/project/template/ios-watch-extension-config.rb b/lib/motion/project/template/ios-watch-extension-config.rb index 7b889cf8..dee3d05e 100644 --- a/lib/motion/project/template/ios-watch-extension-config.rb +++ b/lib/motion/project/template/ios-watch-extension-config.rb @@ -30,8 +30,24 @@ module Motion; module Project; class IOSWatchExtensionConfig < IOSExtensionConfig register :'ios-extension' + def initialize(*) + super + @name = ENV['RM_TARGET_HOST_APP_NAME'] + ' WatchKit Extension' + end + + def name=(name) + App.fail 'You cannot give a Watch app a custom name, it will ' \ + 'automatically be named after the host application.' + end + def info_plist_data(platform) info_plist['CFBundleIdentifier'] = identifier + '.watchkitextension' + info_plist['NSExtension'] = { + 'NSExtensionPointIdentifier' => 'com.apple.watchkit', + 'NSExtensionAttributes' => { + 'WKAppBundleIdentifier' => watch_app_config.identifier + }, + } super end @@ -135,6 +151,7 @@ EOS plist = super plist['UIDeviceFamily'] << '4' # Probably means Apple Watch device? plist['WKWatchKitApp'] = true + plist['WKCompanionAppBundleIdentifier'] = ENV['RM_TARGET_HOST_APP_IDENTIFIER'] plist.delete('UIBackgroundModes') plist.delete('UIStatusBarStyle') plist diff --git a/lib/motion/project/template/ios-watch-extension/files/Rakefile.erb b/lib/motion/project/template/ios-watch-extension/files/Rakefile.erb index d17c6990..61ace936 100644 --- a/lib/motion/project/template/ios-watch-extension/files/Rakefile.erb +++ b/lib/motion/project/template/ios-watch-extension/files/Rakefile.erb @@ -10,13 +10,6 @@ end Motion::Project::App.setup do |app| # Use `rake config' to see complete project settings. - app.name = '<%= name %> WatchKit Extension' app.frameworks << "WatchKit" - app.info_plist['NSExtension'] = { - 'NSExtensionAttributes' => { - 'WKAppBundleIdentifier' => app.identifier + '.watchapp' - }, - 'NSExtensionPointIdentifier' => 'com.apple.watchkit' - } app.info_plist['RemoteInterfacePrincipalClass'] = 'InterfaceController' end