diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..48fee14 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "build_options_helper"] + path = xcode/config_generator/build_options_helper + url = https://github.com/petropavel13/build_options_helper diff --git a/xcode/config_generator/build_options_helper b/xcode/config_generator/build_options_helper new file mode 160000 index 0000000..957fb64 --- /dev/null +++ b/xcode/config_generator/build_options_helper @@ -0,0 +1 @@ +Subproject commit 957fb642a4348923377a625b521d1812620384ba diff --git a/xcode/config_generator/custom_settings.json b/xcode/config_generator/custom_settings.json deleted file mode 100644 index a190324..0000000 --- a/xcode/config_generator/custom_settings.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "targets": [ - { - "YOUR_TARGET_NAME": { - "Standard": { - "PROVISIONING_PROFILE_SPECIFIER": "", - "PRODUCT_BUNDLE_IDENTIFIER": "", - "CODE_SIGN_ENTITLEMENTS": "" - }, - - "Enterprise": { - "PROVISIONING_PROFILE_SPECIFIER": "", - "PRODUCT_BUNDLE_IDENTIFIER": "", - "CODE_SIGN_ENTITLEMENTS": "" - }, - - "AppStore": { - "DEVELOPMENT_TEAM": "", - "PRODUCT_BUNDLE_IDENTIFIER": "", - "CODE_SIGN_ENTITLEMENTS": "" - } - } - } - ] -} diff --git a/xcode/config_generator/example_settings.yaml b/xcode/config_generator/example_settings.yaml new file mode 100644 index 0000000..608981a --- /dev/null +++ b/xcode/config_generator/example_settings.yaml @@ -0,0 +1,27 @@ +targets: + TestProject: + development: + PRODUCT_BUNDLE_IDENTIFIER: "ru.touchin.testproject" + PROVISIONING_PROFILE_SPECIFIER: "TestProjectDev" + CODE_SIGN_ENTITLEMENTS: "TestProject/Standard.entitlements" + enterprise: + PRODUCT_BUNDLE_IDENTIFIER: "com.touchin.testproject" + PROVISIONING_PROFILE_SPECIFIER: "TestProjectEnterprise" + CODE_SIGN_ENTITLEMENTS: "TestProject/Enterprise.entitlements" + appstore: + PRODUCT_BUNDLE_IDENTIFIER: "ru.customer.domain" + PROVISIONING_PROFILE_SPECIFIER: "TestProjectAppStore" + CODE_SIGN_ENTITLEMENTS: "TestProject/Production.entitlements" + +types: + development: + apple_id: "apple@touchin.ru" + team_id: "**********" + itc_team_id: "**********" + enterprise: + apple_id: "enterpriseapple@touchin.ru" + team_id: "**********" + appstore: + apple_id: "apple@touchin.ru" + team_id: "**********" + itc_team_id: "**********" \ No newline at end of file diff --git a/xcode/config_generator/gen_configurations.py b/xcode/config_generator/gen_configurations.py deleted file mode 100644 index 22845ed..0000000 --- a/xcode/config_generator/gen_configurations.py +++ /dev/null @@ -1,94 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -from __future__ import unicode_literals # python 2/3 support - -from itertools import chain -import json - -distribution_options = ["Enterprise", "Standard"] -server_type_options = ["Mock", "Touchin", "Customer"] -server_environment_options = ["Dev", "Test", "Stage", "Prod"] -ssl_pinning_options = ["WithSSLPinning", "WithoutSSLPinning"] -build_type_options = ["Debug", "Release"] - -all_options = [ - distribution_options, - server_type_options, - server_environment_options, - ssl_pinning_options, - build_type_options -] - -def combine_string_with_options(all_options, string="", applied_options=[]): - if len(all_options) == 0: - yield string, applied_options - return - - for current_option in chain.from_iterable(all_options[:1]): - for result_tuple in combine_string_with_options(all_options[1:], string + current_option, applied_options + [current_option]): - yield result_tuple - - yield ("AppStoreRelease", ['AppStore', 'Customer', 'Prod', 'WithSSLPinning', 'Release']) - -def make_config_dict(args): - config_name, applied_options = args - - if "Enterprise" in applied_options: - account_type = "Enterprise" - elif "Standard" in applied_options: - account_type = "Standard" - else: - account_type = "AppStore" - - if "Debug" in applied_options: - build_type = "debug" - elif "AppStore" in applied_options: - build_type = "appstore" - else: - build_type = "release" - - return { - "name": config_name, - "build_type": build_type, - "account_type": account_type, - "xcconfig_options": [ - { - "key": "SWIFT_ACTIVE_COMPILATION_CONDITIONS", - "value": " ".join(map(lambda option: option.upper(), applied_options)) - }, - { - "key": "DEBUG_INFORMATION_FORMAT", - "value": "dwarf" if "Debug" in applied_options else "dwarf-with-dsym" - }, - { - "key": "VALIDATE_PRODUCT", - "value": "NO" if "Debug" in applied_options else "YES" - }, - { - "key": "ENABLE_TESTABILITY", - "value": "YES" if "Debug" in applied_options else "NO" - }, - { - "key": "CODE_SIGN_IDENTITY", - "value": "iPhone Developer" if account_type == "Standard" else "iPhone Distribution" - }, - { - "key": "GCC_OPTIMIZATION_LEVEL", - "value": "0" if "Debug" in applied_options else "s" - }, - { - "key": "SWIFT_OPTIMIZATION_LEVEL", - "value": "-Onone" if "Debug" in applied_options else "-O" - }, - { - "key": "SWIFT_COMPILATION_MODE", - "value": "singlefile" if "Debug" in applied_options else "wholemodule" - } - ] - } - - -config_dicts = map(make_config_dict, combine_string_with_options(all_options)) - -print(json.dumps({"configurations": config_dicts}, indent=4)) diff --git a/xcode/config_generator/render_xcconfigs.rb b/xcode/config_generator/render_xcconfigs.rb index dd041d8..197c382 100755 --- a/xcode/config_generator/render_xcconfigs.rb +++ b/xcode/config_generator/render_xcconfigs.rb @@ -4,7 +4,7 @@ require 'yaml' # Usage: render_xcconfigs.rb # -# Result: Adds .xcconfig files to $configs_folder_name directory. +# Result: Adds .xcconfig files to $configs_folder_name directory. # Files are only being added and changed, not removed! # It is recommended to remove old .xcconfig files before running this script. @@ -21,14 +21,15 @@ end # Input files paths configurations_file_path = ARGV[0] temp_configs_data_file_path = "configs_data.json".in_current_dir -generator_path = "gen_configurations.py".in_current_dir +generator_path = "build_options_helper/helper.py".in_current_dir template_path = "target_xcconfig.mustache".in_current_dir +build_parameters_path = ARGV[1] || "build_parameters.yaml".in_current_dir # Create config directory if needed Dir.mkdir($configs_folder_name) unless Dir.exist?($configs_folder_name) # Call python script and generate configs to config file -system("python #{generator_path} > #{temp_configs_data_file_path}") +system("python #{generator_path} -bp #{build_parameters_path} -o . -r ios_build_settings -p ios") # Open settings, configurations and template files target_xcconfig_tempate = File.read(template_path) @@ -53,7 +54,7 @@ def distribution_type_of(account_type) when "AppStore" "appstore" else - raise "Error: Unsupported distribution type #{account_type}" + raise "Error: Unsupported distribution type #{account_type}" end end @@ -77,16 +78,16 @@ end def generate_google_service_info_plist_path(google_service_info_plist_key, target_name, distribution_type) google_service_info_plist_path = target_name + "/Resources/" - + path_suffix = case distribution_type when "development" "Standard-GoogleService-Info.plist" when "enterprise" "Enterprise-GoogleService-Info.plist" - else + else "AppStore-GoogleService-Info.plist" end - + return config_option(google_service_info_plist_key, google_service_info_plist_path + path_suffix) end @@ -110,7 +111,7 @@ def generate_missing_properties(target_name, properties, distribution_type) unless properties.key?(provisioning_key) result.append(generate_provisioning_profile(provisioning_key, bundle_id, distribution_type)) end - + unless properties.key?(google_service_info_plist_key) result.append(generate_google_service_info_plist_path(google_service_info_plist_key, target_name, distribution_type)) end @@ -122,11 +123,11 @@ end targets.each do |target_name, target| # Need open everytime, because script make some changes only for this target - configs = JSON.load(File.open(temp_configs_data_file_path))["configurations"] + configs = JSON.load(File.open(temp_configs_data_file_path)) # Run through all configs configs.each do |config| - + # Take default values distribution_type = distribution_type_of(config["account_type"]) properties = target[distribution_type]