From dbfc6153ab5a96761b1307f7fa163dc0d527ba87 Mon Sep 17 00:00:00 2001 From: Vlad Date: Sat, 12 Dec 2020 18:17:39 +0300 Subject: [PATCH] Add uploadFeaturesToProject lane --- xcode/commonFastfile | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/xcode/commonFastfile b/xcode/commonFastfile index 3886625..3d82867 100644 --- a/xcode/commonFastfile +++ b/xcode/commonFastfile @@ -106,6 +106,26 @@ private_lane :addShield do |options| end end +private_lane :uploadFeaturesToProject do |options| + require 'json' + + features_string = options[:features] # "DebitCardFeature,Sprint5Feature,CreditCardFeature" + feature_names = features_string.split(",").map { |value| value.strip } # [ "DebitCardFeature", "Sprint5Feature", "CreditCardFeature" ] + + # Generate JSON from feature names + feature_bodies = feature_names.map { |feature_name| { :name => feature_name, :enabled => true} } + features = { :features => features_body } + features_json = JSON.pretty_generate(features) + + # Put features JSON to project file + app_target_folder_name = options[:appName] || $appName + features_file_path = get_features_file_path(app_target_folder_name) + + File.open(features_file_path, "w") do |f| + f.write(features_json) + end +end + private_lane :buildConfiguration do |options| appName = options[:appName] || $appName @@ -136,6 +156,10 @@ private_lane :buildConfiguration do |options| installDependencies(options) + if options[:features] + uploadFeaturesToProject(options) + end + if !(options[:uploadToFabric] || options[:uploadToAppStore]) options[:skip_package_ipa] = true @@ -397,6 +421,10 @@ def get_google_services_plist_path(app_target_folder_name, configuration_type) File.expand_path "../#{app_target_folder_name}/Resources/#{configuration_type.prefix}-GoogleService-Info.plist" end +def get_features_file_path(app_target_folder_name) + File.expand_path "../#{app_target_folder_name}/Resources/Features.json" +end + def set_xcconfig_for_configuration_of_project(lane_name, configuration, xcodeproj_path) require 'xcodeproj'