From 21f159b4f812d83e0e5ffb9482d401423f9f62da Mon Sep 17 00:00:00 2001 From: Ivan Smolin Date: Fri, 26 Jul 2019 16:34:21 +0300 Subject: [PATCH] build Release configuration with specific xcconfig --- xcode/commonFastfile | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/xcode/commonFastfile b/xcode/commonFastfile index 73e596c..fb4884c 100644 --- a/xcode/commonFastfile +++ b/xcode/commonFastfile @@ -122,6 +122,8 @@ private_lane :buildArchive do |options| exportOptions = icloudEnvironment.to_s.empty? ? {} : {iCloudContainerEnvironment: icloudEnvironment} exportOptions[:compileBitcode] = options[:compileBitcode] || false + set_xcconfig_for_configuration_of_project(options[:configuration], "Release", options[:xcodeproj_path]) + gym( clean: true, workspace: options[:workspace], @@ -129,7 +131,7 @@ private_lane :buildArchive do |options| archive_path: "./", output_directory: "./", output_name: options[:output_name], - configuration: options[:configuration], + configuration: "Release", export_method: options[:method], export_options: exportOptions, skip_package_ipa: options[:skip_package_ipa], @@ -307,3 +309,19 @@ end def fabric_keys_from_shell_script(shell_script_contents) shell_script_contents.gsub("\\n", "").partition('Fabric/run\" ').last.partition('";').first.split(" ") end + +def set_xcconfig_for_configuration_of_project(xcconfig_name, configuration_name, xcodeproj_path) + require 'xcodeproj' + + project = Xcodeproj::Project.open(xcodeproj_path) + + is_app_target = lambda { |t| !t.test_target_type? && t.product_type == Xcodeproj::Constants::PRODUCT_TYPE_UTI[:application] } + application_target = project.native_targets.select(&is_app_target).first + build_configuration = application_target.build_configuration_list[configuration_name] + + build_configuration_reference = project.files.select { |f| f.path.start_with?(xcconfig_name) }.first + + build_configuration.base_configuration_reference = build_configuration_reference + + project.save() +end