From 66a2fda126f579c1b3e6c570dcd1d4968a60287e Mon Sep 17 00:00:00 2001 From: petropavel13 Date: Wed, 20 Jan 2021 11:17:06 +0300 Subject: [PATCH 1/2] Merge pull request #243 from TouchInstinct/feature/fastlane_app_store_connect_api use App Store Connect API for match and upload_to_app_store --- xcode/commonFastfile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/xcode/commonFastfile b/xcode/commonFastfile index 04671fd..8414758 100644 --- a/xcode/commonFastfile +++ b/xcode/commonFastfile @@ -1,4 +1,5 @@ $appName = File.basename(Dir['../*.xcworkspace'].first, '.*') +$API_KEY_PATH="fastlane/api_key.json" require_relative 'fastlane/touchlane/lib/touchlane' @@ -85,6 +86,7 @@ end private_lane :uploadToAppStore do |options| upload_to_app_store( username: options[:username] || options[:apple_id], + api_key_path: $API_KEY_PATH, ipa: options[:ipa_path], force: true, # skip metainfo prompt skip_metadata: true, @@ -234,8 +236,8 @@ lane :SyncSymbols do |options| xcodeproj_path = File.expand_path "../#{appName}.xcodeproj" - version_number = options[:version] || get_version_number(xcodeproj: xcodeproj_path, target: appName) - build_number = options[:build_number] || get_build_number(xcodeproj: xcodeproj_path) + version_number = options[:version] || "latest" + build_number = options[:build_number] if configuration.type.is_app_store download_dsyms( @@ -346,6 +348,7 @@ def sync_code_signing_using_options(options) match( app_identifier: options[:app_identifier], username: options[:username] || options[:apple_id], + api_key_path: $API_KEY_PATH, team_id: options[:team_id], type: options[:type], readonly: options[:readonly].nil? ? true : options[:readonly], From eee2c487b0e39253b41019f1208794e54c20a174 Mon Sep 17 00:00:00 2001 From: petropavel13 Date: Thu, 11 Feb 2021 18:27:53 +0300 Subject: [PATCH 2/2] Merge pull request #244 from TouchInstinct/feature/api_key_fixes use two api keys: project and touchin # Conflicts: # xcode/commonFastfile --- xcode/commonFastfile | 55 ++++++++++++++++--- .../lib/touchlane/configuration_type.rb | 17 ++++-- 2 files changed, 57 insertions(+), 15 deletions(-) diff --git a/xcode/commonFastfile b/xcode/commonFastfile index 8414758..c2b96fd 100644 --- a/xcode/commonFastfile +++ b/xcode/commonFastfile @@ -1,5 +1,4 @@ $appName = File.basename(Dir['../*.xcworkspace'].first, '.*') -$API_KEY_PATH="fastlane/api_key.json" require_relative 'fastlane/touchlane/lib/touchlane' @@ -83,15 +82,16 @@ private_lane :uploadToFirebase do |options| ) end -private_lane :uploadToAppStore do |options| +def upload_to_app_store_using_options(options) upload_to_app_store( username: options[:username] || options[:apple_id], - api_key_path: $API_KEY_PATH, + api_key_path: options[:api_key_path], ipa: options[:ipa_path], force: true, # skip metainfo prompt skip_metadata: true, team_id: options[:itc_team_id], - dev_portal_team_id: options[:team_id] + dev_portal_team_id: options[:team_id], + precheck_include_in_app_purchases: false ) end @@ -166,7 +166,7 @@ private_lane :buildConfiguration do |options| sync_code_signing_using_options(options) buildArchive(options) - uploadToAppStore(options) + upload_to_app_store_using_options(options) end end @@ -348,7 +348,7 @@ def sync_code_signing_using_options(options) match( app_identifier: options[:app_identifier], username: options[:username] || options[:apple_id], - api_key_path: $API_KEY_PATH, + api_key_path: options[:api_key_path], team_id: options[:team_id], type: options[:type], readonly: options[:readonly].nil? ? true : options[:readonly], @@ -373,7 +373,16 @@ end def fill_up_options_using_configuration_type(options, configuration_type) configuration = get_configuration_for_type(configuration_type.type) - configuration.to_options + if configuration_type.is_app_store || configuration_type.is_development + api_key_path = "fastlane/#{configuration_type.prefix}_api_key.json" + else + api_key_path = nil + end + + default_options = {:api_key_path => api_key_path} + + default_options + .merge(configuration.to_options) .merge(get_keychain_options(options)) .merge(options) end @@ -405,7 +414,35 @@ 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 set_xcconfig_for_configuration_of_project(xcconfig_name, configuration, xcodeproj_path) +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' project = Xcodeproj::Project.open(xcodeproj_path) @@ -422,7 +459,7 @@ def set_xcconfig_for_configuration_of_project(xcconfig_name, configuration, xcod application_targets.each do |target| build_configuration = target.build_configuration_list[configuration] - config_name = target.name + xcconfig_name + config_name = target.name + lane_name build_configuration_reference = project.files.select { |f| f.path.start_with?(config_name) }.first build_configuration.base_configuration_reference = build_configuration_reference end diff --git a/xcode/fastlane/touchlane/lib/touchlane/configuration_type.rb b/xcode/fastlane/touchlane/lib/touchlane/configuration_type.rb index a47434e..96f5412 100644 --- a/xcode/fastlane/touchlane/lib/touchlane/configuration_type.rb +++ b/xcode/fastlane/touchlane/lib/touchlane/configuration_type.rb @@ -14,16 +14,21 @@ module Touchlane def initialize(type) @type = type + @is_app_store = type == APP_STORE + @is_development = type == DEVELOPMENT + case type - when DEVELOPMENT, ENTERPRISE + when DEVELOPMENT @export_method = type - @configuration = type == DEVELOPMENT ? "Debug" : "Release" - @is_app_store = false - @prefix = type == DEVELOPMENT ? DEVELOPMENT_PREFIX : ENTERPRISE_PREFIX + @configuration = "Debug" + @prefix = DEVELOPMENT_PREFIX + when ENTERPRISE + @export_method = type + @configuration = "Release" + @prefix = ENTERPRISE_PREFIX when APP_STORE @export_method = "app-store" @configuration = "AppStore" - @is_app_store = true @prefix = APP_STORE_PREFIX else raise "Unknown type passed #{type}" @@ -32,7 +37,7 @@ module Touchlane private_class_method :new - attr_reader :export_method, :type, :configuration, :is_app_store, :prefix + attr_reader :export_method, :type, :configuration, :is_app_store, :is_development, :prefix def self.from_lane_name(lane_name) case