bin/nixenvironment in nixenvironment-0.0.50 vs bin/nixenvironment in nixenvironment-0.0.51
- old
+ new
@@ -86,10 +86,15 @@
if need_to_build_ios
begin
read_config_settings
+ if @config_settings['WORKSPACE_TO_BUILD'] and @config_settings['WORKSPACE_TO_BUILD'].length > 0
+ scheme = @config_settings['WORKSPACE_SCHEME_TO_BUILD']
+ abort("Build error! Scheme #{scheme} doesn't exist") unless xcode_project_contains_scheme?(scheme)
+ end
+
if is_unity_platform
@config_settings['ICONS_PATH'] = 'Unity-iPhone/Images.xcassets' unless $icons_path
end
enable_ci_build(options.ci_build)
@@ -336,10 +341,13 @@
cmd_output = %x[ xcodebuild -workspace \"#{@config_settings['WORKSPACE_TO_BUILD']}\"\
-scheme \"#{@config_settings['WORKSPACE_SCHEME_TO_BUILD']}\"\
-configuration \"#{config}\"\
-sdk \"#{@config_settings['SDK']}\"\
-showBuildSettings ]
+
+ @unescaped_watchkit_extension_product_settings_path = unescaped_product_settings_path(' WatchKit Extension', config)
+ @unescaped_watchkit_app_product_settings_path = unescaped_product_settings_path(' WatchKit App', config)
else
abort('Build error! Either PROJECT_TO_BUILD or WORKSPACE_TO_BUILD must be specified!')
end
# $? - last cmd exit code
@@ -371,14 +379,54 @@
@config_settings['CONFIGURATION_BUILD_DIR'] = build_directory
@config_settings['BUILT_PRODUCTS_DIR'] = build_directory
@config_settings['DWARF_DSYM_FOLDER_PATH'] = build_directory
end
+def unescaped_product_settings_path(scheme_suffix, config)
+ scheme = @config_settings['WORKSPACE_SCHEME_TO_BUILD'] + scheme_suffix
+ if xcode_project_contains_scheme?(scheme)
+ cmd_output = %x[ xcodebuild -workspace \"#{@config_settings['WORKSPACE_TO_BUILD']}\"\
+ -scheme \"#{scheme}\"\
+ -showBuildSettings ]
+ # Parse build settings
+ env_vars_list = cmd_output.split(/\n/).reject(&:empty?)
+ if env_vars_list and env_vars_list.length > 0
+ build_settings_to_strip = Hash.new.compare_by_identity
+ env_vars_list.each do |it|
+ key_value = it.split('=', 2)
+ build_settings_to_strip[key_value[0]] = key_value[1]
+ end
+
+ build_settings_to_strip.each do |key, value|
+ if key and value
+ stripped_key = key.strip
+ stripped_value = value.strip
+ if stripped_key == 'PRODUCT_SETTINGS_PATH'
+ if stripped_value.include?(scheme_suffix)
+ return stripped_value
+ end
+ end
+ end
+ end
+ end
+ end
+
+ nil
+end
+
def xcode_project_contains_config?(config)
+ xcode_project_info['Build Configurations'].include?(config)
+end
+
+def xcode_project_contains_scheme?(scheme)
+ xcode_project_info['Schemes'].include?(scheme)
+end
+
+def xcode_project_info
# Parse information about project
cmd_output = %x[ xcodebuild -list 2>&1 ]
- abort("Validate configuration error! #{cmd_output}") if cmd_output.include?('error')
+ abort("Getting xcode_project_info error! #{cmd_output}") if cmd_output.include?('error')
cmd_output = cmd_output.lines[1..-1].join # Get all lines except first in order to ignore description message
info = {}
@@ -388,11 +436,11 @@
lines = value.lines.map { |line| line.strip }
lines.reject! { |line| line.empty? }
info[key.strip] = lines
end
- info['Build Configurations'].include?(config)
+ info
end
def save_build_env_vars
app_product = File.join(@config_settings['BUILT_PRODUCTS_DIR'], @config_settings['EXECUTABLE_NAME']) + '.app'
@@ -605,10 +653,28 @@
@info_plist_backup_name = @unescaped_product_settings_path + '.backup'
FileUtils.cp(@unescaped_product_settings_path, @info_plist_backup_name)
p('Info.plist was backuped.')
+
+ unless @unescaped_watchkit_app_product_settings_path.nil?
+ p('Backuping WatchKit App Info.plist ...')
+
+ @watchkit_app_info_plist_backup_name = @unescaped_watchkit_app_product_settings_path + '.backup'
+ FileUtils.cp(@unescaped_watchkit_app_product_settings_path, @watchkit_app_info_plist_backup_name)
+
+ p('WatchKit App Info.plist was backuped.')
+ end
+
+ unless @unescaped_watchkit_extension_product_settings_path.nil?
+ p('Backuping WatchKit Extension Info.plist ...')
+
+ @watchkit_extension_info_plist_backup_name = @unescaped_watchkit_extension_product_settings_path + '.backup'
+ FileUtils.cp(@unescaped_watchkit_extension_product_settings_path, @watchkit_extension_info_plist_backup_name)
+
+ p('WatchKit Extension Info.plist was backuped.')
+ end
end
def update_info_plist(config)
p('Updating Info.plist ...')
@@ -624,18 +690,60 @@
restore_info_plist
abort('Update Info.plist error!')
end
p('Info.plist was updated.')
+
+ unless @unescaped_watchkit_app_product_settings_path.nil?
+ p('Updating WatchKit App Info.plist ...')
+
+ update_success = system("/usr/libexec/PlistBuddy -c 'Set :CFBundleVersion \"#{monotonic_revision}\"' \"#{@unescaped_watchkit_app_product_settings_path}\"")
+ unless update_success
+ restore_info_plist
+ abort('Update WatchKit App Info.plist error!')
+ end
+
+ p('WatchKit App Info.plist was updated.')
+ end
+
+ unless @unescaped_watchkit_extension_product_settings_path.nil?
+ p('Updating Extension App Info.plist ...')
+
+ update_success = system("/usr/libexec/PlistBuddy -c 'Set :CFBundleVersion \"#{monotonic_revision}\"' \"#{@unescaped_watchkit_extension_product_settings_path}\"")
+ unless update_success
+ restore_info_plist
+ abort('Update WatchKit Extension Info.plist error!')
+ end
+
+ p('WatchKit Extension Info.plist was updated.')
+ end
end
def restore_info_plist
p('Restoring Info.plist ...')
File.delete(@unescaped_product_settings_path)
File.rename(@info_plist_backup_name, @unescaped_product_settings_path)
p('Info.plist was restored.')
+
+ unless @unescaped_watchkit_app_product_settings_path.nil?
+ p('Restoring WatchKit App Info.plist ...')
+
+ File.delete(@unescaped_watchkit_app_product_settings_path)
+ File.rename(@watchkit_app_info_plist_backup_name, @unescaped_watchkit_app_product_settings_path)
+
+ p('WatchKit App Info.plist was restored.')
+ end
+
+ unless @unescaped_watchkit_extension_product_settings_path.nil?
+ p('Restoring WatchKit Extension Info.plist ...')
+
+ File.delete(@unescaped_watchkit_extension_product_settings_path)
+ File.rename(@watchkit_extension_info_plist_backup_name, @unescaped_watchkit_extension_product_settings_path)
+
+ p('WatchKit Extension Info.plist was restored.')
+ end
end
def deploy(deliver_deploy)
deploy = File.join(BUILD_SCRIPTS_PATH, 'DeployIPA.sh')