From 20d4e506983a61a483c81035236513cd541c7104 Mon Sep 17 00:00:00 2001 From: Sergey Kopytov Date: Fri, 13 Sep 2019 14:15:48 +0300 Subject: [PATCH] refactor --- xcode/config_generator/Readme.md | 3 --- xcode/config_generator/render_xcconfigs.rb | 14 +++++++++----- xcode/config_generator/settings.json | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) delete mode 100644 xcode/config_generator/Readme.md diff --git a/xcode/config_generator/Readme.md b/xcode/config_generator/Readme.md deleted file mode 100644 index 77fe832..0000000 --- a/xcode/config_generator/Readme.md +++ /dev/null @@ -1,3 +0,0 @@ -# Генератор конфигурационных файлов в формате `.xcconfig` - - здесь должна быть инструкция или ссылка на нее \ No newline at end of file diff --git a/xcode/config_generator/render_xcconfigs.rb b/xcode/config_generator/render_xcconfigs.rb index 750a2e7..a3eecb5 100644 --- a/xcode/config_generator/render_xcconfigs.rb +++ b/xcode/config_generator/render_xcconfigs.rb @@ -1,10 +1,14 @@ require 'json' require 'mustache' +# Constants +configs_folder_name = "TargetConfigurations" +standard_dev_team = "D4HA43V467" +enterprise_dev_team = "228J5MMU7S" # create config files if needed -system("touch configs_data.json") unless File.exist?("configs_data") -system("mkdir TargetConfigurations") unless Dir.exist?("TargetConfigurations") +File.new("configs_data.json", 'a') +Dir.mkdir(configs_folder_name) unless Dir.exist?(configs_folder_name) # call python script and generate configs to config file system("python gen_configurations.py > configs_data.json") @@ -30,7 +34,7 @@ def development_team_if_needed(properties, account_type) return [] end - team_value = account_type == "Standard" ? "D4HA43V467" : "228J5MMU7S" + team_value = account_type == "Standard" ? standard_dev_team : enterprise_dev_team return [config_option(development_team_key, team_value)] end @@ -87,7 +91,7 @@ targets.each do |target| } # create file for every setting in loop - File.open("TargetConfigurations/" + target_name + config["name"] + ".xcconfig", 'w') { |file| + File.open(configs_folder_name + "/" + target_name + config["name"] + ".xcconfig", 'w') { |file| file.puts(Mustache.render(target_xcconfig_tempate, config_data)) } end @@ -95,4 +99,4 @@ targets.each do |target| end # remove config file, it's trash -system("rm configs_data.json") if File.exist?("configs_data.json") +File.delete("configs_data.json") if File.exist?("configs_data.json") diff --git a/xcode/config_generator/settings.json b/xcode/config_generator/settings.json index d70867d..a190324 100644 --- a/xcode/config_generator/settings.json +++ b/xcode/config_generator/settings.json @@ -1,7 +1,7 @@ { "targets": [ { - "target_name": { + "YOUR_TARGET_NAME": { "Standard": { "PROVISIONING_PROFILE_SPECIFIER": "", "PRODUCT_BUNDLE_IDENTIFIER": "",