mirror of
https://github.com/zhigang1992/RubyMotion.git
synced 2026-04-07 17:47:52 +08:00
[WatchKit] Move configuration to config objects.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user