From e44811d1b73f48a1b2c12456dfe0823a5151a953 Mon Sep 17 00:00:00 2001 From: Ivan Smolin Date: Wed, 17 Jan 2024 12:25:46 +0300 Subject: [PATCH] remove unused actions and methods --- xcode/commonFastfile | 52 ------------------- .../touchlane/lib/touchlane/features.rb | 26 ---------- xcode/managers/lib/file_manager.rb | 33 ------------ xcode/managers/lib/template_manager.rb | 19 ------- xcode/managers/managers.rb | 4 -- xcode/templates/templates.rb | 3 -- .../templates/templates/features_templates.rb | 34 ------------ 7 files changed, 171 deletions(-) delete mode 100644 xcode/fastlane/touchlane/lib/touchlane/features.rb delete mode 100644 xcode/managers/lib/file_manager.rb delete mode 100644 xcode/managers/lib/template_manager.rb delete mode 100644 xcode/managers/managers.rb delete mode 100644 xcode/templates/templates.rb delete mode 100755 xcode/templates/templates/features_templates.rb diff --git a/xcode/commonFastfile b/xcode/commonFastfile index e95320d..09e8757 100644 --- a/xcode/commonFastfile +++ b/xcode/commonFastfile @@ -1,7 +1,6 @@ $appName = File.basename(Dir['../*.xcworkspace'].first, '.*') require_relative 'fastlane/touchlane/lib/touchlane' -require_relative 'managers/managers' # ugly hack to add support for custom storage @@ -120,7 +119,6 @@ private_lane :buildConfiguration do |options| installDependencies(options) run_code_generation_phase_if_needed(options) - generate_enabled_features_extension_if_needed(options) if !(options[:uploadToFabric] || options[:uploadToAppStore]) options[:skip_package_ipa] = true @@ -194,28 +192,6 @@ private_lane :buildArchive do |options| ) end -lane :CreatePushCertificate do |options| - configuration = get_configuration_for_type(options[:type] || "development") - options = configuration.to_options.merge(options) - - certificates_path = File.expand_path "../Certificates" - Dir.mkdir(certificates_path) unless File.directory?(certificates_path) - - app_identifier = options[:app_identifier] - - get_push_certificate( - development: options[:development].nil? ? true : options[:development], - generate_p12: true, - active_days_limit: 30, # create new certificate if old one will expire in 30 days - save_private_key: false, - app_identifier: (app_identifier.is_a? Array) ? app_identifier.first : app_identifier, - username: options[:username] || options[:apple_id], - team_id: options[:team_id], - p12_password: "123", # empty password won't work with Pusher - output_path: certificates_path - ) -end - lane :SyncCodeSigning do |options| configuration_type = Touchlane::ConfigurationType.from_type(options[:type]) options = fill_up_options_using_configuration_type(options, configuration_type) @@ -414,34 +390,6 @@ def get_google_services_plist_path(app_target_folder_name, configuration_type) File.expand_path "../#{app_target_folder_name}/Resources/GoogleService-Info.plist" end -def generate_enabled_features_extension_if_needed(options) - app_target_folder_name = options[:appName] || $appName - - project_enabled_features_file_path = File.expand_path "../#{app_target_folder_name}/Resources/Features/Enabled.swift" - build_settings_file_path = File.expand_path "../common/build_settings.yaml" - - unless is_feature_extension_needed?(options, project_enabled_features_file_path) - return - end - - if options[:features].nil? - builder_features_list = [] # If Enabled.swift exists and features option is nil we need to create empty extension to avoid unexpected features - else - builder_features_list = options[:features] - .split(",").map { |feature_name| feature_name.strip } # [ "Feature1", "Feature2", "Feature3" ] - end - - build_settings_features_list = Managers::FileManager.load_from_file_YAML(build_settings_file_path)["features"] - - enabled_features_extension = Touchlane::Features.generate_enabled_features_extension(builder_features_list, build_settings_features_list) - - Managers::FileManager.save_data_to_file(project_enabled_features_file_path, enabled_features_extension) -end - -def is_feature_extension_needed?(options, project_enabled_features_file_path) - !options[:features].nil? || File.exists?(project_enabled_features_file_path) -end - def set_xcconfig_for_configuration_of_project(lane_name, configuration, xcodeproj_path) require 'xcodeproj' diff --git a/xcode/fastlane/touchlane/lib/touchlane/features.rb b/xcode/fastlane/touchlane/lib/touchlane/features.rb deleted file mode 100644 index cadfb0f..0000000 --- a/xcode/fastlane/touchlane/lib/touchlane/features.rb +++ /dev/null @@ -1,26 +0,0 @@ -require_relative '../../../../managers/managers' -require_relative '../../../../templates/templates' - -module Touchlane - class Features - - def self.generate_enabled_features_extension(builder_features_list, build_settings_features_list) - - # Check is entered features contains in configuration file - features_diff = builder_features_list - build_settings_features_list - - unless features_diff.empty? - raise "Unexpected features: " + features_diff.join(', ') - end - - # Generate enabled features extension from feature names - enabled_features_extension_template = Templates::FeatureTemplates.enabled_features_extension - utils = Managers::TemplateManager.new(builder_features_list) - - utils.render(enabled_features_extension_template).strip - end - - private_class_method :new - - end -end diff --git a/xcode/managers/lib/file_manager.rb b/xcode/managers/lib/file_manager.rb deleted file mode 100644 index 45bdda8..0000000 --- a/xcode/managers/lib/file_manager.rb +++ /dev/null @@ -1,33 +0,0 @@ -require 'yaml' -require 'json' - -module Managers - class FileManager - - def self.save_data_to_file(path, data) - unless File.exists? path - raise "Unable to save data to file at #{path}" - else - File.open(path, "w") do |f| - f.write(data) - end - end - end - - def self.load_from_file_YAML(path) - unless File.exists? path - raise "Unable to load data from file at #{path}" - else - YAML.load_file(path) - end - end - - def self.save_data_to_file_in_json(path, data) - json_data = JSON.pretty_generate(data) - save_data_to_file(path, json_data) - end - - private_class_method :new - - end -end diff --git a/xcode/managers/lib/template_manager.rb b/xcode/managers/lib/template_manager.rb deleted file mode 100644 index adb59c5..0000000 --- a/xcode/managers/lib/template_manager.rb +++ /dev/null @@ -1,19 +0,0 @@ -require 'erb' - -module Managers - class TemplateManager - - include ERB::Util - - attr_accessor :items - - def initialize(items) - @items = items - end - - def render(template) - ERB.new(template).result(binding) - end - - end -end diff --git a/xcode/managers/managers.rb b/xcode/managers/managers.rb deleted file mode 100644 index 9c3c53d..0000000 --- a/xcode/managers/managers.rb +++ /dev/null @@ -1,4 +0,0 @@ -module Managers - require_relative "lib/file_manager" - require_relative "lib/template_manager" -end diff --git a/xcode/templates/templates.rb b/xcode/templates/templates.rb deleted file mode 100644 index c26788d..0000000 --- a/xcode/templates/templates.rb +++ /dev/null @@ -1,3 +0,0 @@ -module Templates - require_relative "templates/features_templates" -end diff --git a/xcode/templates/templates/features_templates.rb b/xcode/templates/templates/features_templates.rb deleted file mode 100755 index 69eeeaf..0000000 --- a/xcode/templates/templates/features_templates.rb +++ /dev/null @@ -1,34 +0,0 @@ -module Templates - module FeatureTemplates - - def self.features_enum -" -// MARK: - Generated feature toggles - -public enum Feature: String, Codable, RawRepresentable, CaseIterable { - <% for @item in @items %> - case <%= @item %> - <% end %> -} -" - end - - def self.enabled_features_extension -" -// MARK: - Generated enabled features - -public extension Feature { - - static var enabled: [Feature] { - [ - <% for @item in @items %> - \.<%= @item %>, - <% end %> - ] - } -} -" - end - - end -end \ No newline at end of file