diff --git a/lib/motion/project/builder.rb b/lib/motion/project/builder.rb index 7958bacd..46be588b 100644 --- a/lib/motion/project/builder.rb +++ b/lib/motion/project/builder.rb @@ -446,12 +446,7 @@ EOS end # Create bundle/Info.plist. - bundle_info_plist = File.join(bundle_path, 'Info.plist') - if !File.exist?(bundle_info_plist) or File.mtime(config.project_file) > File.mtime(bundle_info_plist) - App.info 'Create', bundle_info_plist - File.open(bundle_info_plist, 'w') { |io| io.write(config.info_plist_data(platform)) } - sh "/usr/bin/plutil -convert binary1 \"#{bundle_info_plist}\"" - end + generate_info_plist(config, platform) # Copy resources, handle subdirectories. app_resources_dir = config.app_resources_dir(platform) @@ -571,6 +566,15 @@ EOS sh "'#{File.join(config.bindir, 'instruments')}' '#{instruments_app}' '#{plist_path}'" end + def generate_info_plist(config, platform) + bundle_info_plist = File.join(config.app_bundle(platform), 'Info.plist') + if !File.exist?(bundle_info_plist) or File.mtime(config.project_file) > File.mtime(bundle_info_plist) + App.info 'Create', bundle_info_plist + File.open(bundle_info_plist, 'w') { |io| io.write(config.info_plist_data(platform)) } + sh "/usr/bin/plutil -convert binary1 \"#{bundle_info_plist}\"" + end + end + class << self def common_build_dir dir = File.expand_path("~/Library/RubyMotion/build") diff --git a/lib/motion/project/template/ios-watch-extension-builder.rb b/lib/motion/project/template/ios-watch-extension-builder.rb index 5ead34d5..dc61c7be 100644 --- a/lib/motion/project/template/ios-watch-extension-builder.rb +++ b/lib/motion/project/template/ios-watch-extension-builder.rb @@ -36,6 +36,9 @@ module Motion; module Project # Compile storyboard 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. + generate_info_plist(config, platform) end def build_watch_extension(config, platform, opts) diff --git a/lib/motion/project/template/ios-watch-extension-config.rb b/lib/motion/project/template/ios-watch-extension-config.rb index 9f29d3ef..658680be 100644 --- a/lib/motion/project/template/ios-watch-extension-config.rb +++ b/lib/motion/project/template/ios-watch-extension-config.rb @@ -115,6 +115,29 @@ EOS @name ||= @extension_config.name.sub(" WatchKit Extension", '') + " Watch App" end + # @return [String] The bundle identifier of the watch application based on + # the bundle identifier of the watch extension. + # + def identifier + @identifier ||= @extension_config.identifier + '.watchapp' + end + + # @todo There are more differences with Xcode's Info.plist. + # + # @param [String] platform + # The platform identifier that's being build for, such as + # `iPhoneSimulator` or `iPhoneOS`. + # + # @return [Hash] A hash that contains all the various `Info.plist` data + # merged into one hash. + # + def merged_info_plist(platform) + plist = super + plist['UIDeviceFamily'] << '4' # Probably means Apple Watch device? + plist['WKWatchKitApp'] = true + plist + end + # @param [String] platform # The platform identifier that's being build for, such as # `iPhoneSimulator` or `iPhoneOS`.