class Fastlane::Actions::UpdateBuildSettingsKeyAction
Public Class Methods
available_options()
click to toggle source
# File lib/fastlane/plugin/update_build_settings_key/actions/update_build_settings_key_action.rb, line 52 def self.available_options [ FastlaneCore::ConfigItem.new(key: :xcodeproj, env_name: "FL_PROJECT_SIGNING_PROJECT_PATH", description: "Path to your Xcode project", verify_block: proc do |value| UI.user_error!("Path is invalid") unless File.exist?(value) end), FastlaneCore::ConfigItem.new(key: :configuration, description: "name of your configuration ,such as 'Release'"), FastlaneCore::ConfigItem.new(key: :build_settings_key, description: "key of the build setting you want update"), FastlaneCore::ConfigItem.new(key: :map, type: Hash, description: "KEY is path to Info.plist , VALUE is updated value of build setting key") ] end
description()
click to toggle source
# File lib/fastlane/plugin/update_build_settings_key/actions/update_build_settings_key_action.rb, line 35 def self.description "Updates build settings key to a new value" end
details()
click to toggle source
# File lib/fastlane/plugin/update_build_settings_key/actions/update_build_settings_key_action.rb, line 47 def self.details # Optional: "Updates build settings key to a new value including specific profile,\nwill Update code signing settings from 'Automatic' to a specific profile when key is PROVISIONING_PROFILE_SPECIFIER" end
example_code()
click to toggle source
# File lib/fastlane/plugin/update_build_settings_key/actions/update_build_settings_key_action.rb, line 70 def self.example_code [ 'update_build_settings_key( xcodeproj: "Demo/Demo.xcodeproj", configuration: "Release", build_settings_key: "PROVISIONING_PROFILE_SPECIFIER", map: { "Demo Watch Extension/Info.plist" => "Demo WatchKit Extension 2", "Demo Watch/Info.plist" => "Demo WatchKit App", "Demo Today/Info.plist" => "Demo Today", "Demo/Info.plist" => "Demo" } )' ] end
is_supported?(platform)
click to toggle source
# File lib/fastlane/plugin/update_build_settings_key/actions/update_build_settings_key_action.rb, line 86 def self.is_supported?(platform) # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example) # See: https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Platforms.md # # [:ios, :mac, :android].include?(platform) true end
return_value()
click to toggle source
# File lib/fastlane/plugin/update_build_settings_key/actions/update_build_settings_key_action.rb, line 43 def self.return_value # If your method provides a return value, you can describe here what it does end
run(params)
click to toggle source
# File lib/fastlane/plugin/update_build_settings_key/actions/update_build_settings_key_action.rb, line 4 def self.run(params) require 'plist' require 'xcodeproj' info_plist_key = 'INFOPLIST_FILE' build_settings_key = params[:build_settings_key] project_path = params[:xcodeproj] configuration = params[:configuration] map = params[:map] project = Xcodeproj::Project.open(project_path) # Set ProvisioningStyle to Manual if if 'PROVISIONING_PROFILE_SPECIFIER' == build_settings_key pbxprojects = project.objects.select { |obj| obj.isa == 'PBXProject' } pbxprojects.each { |obj| obj.attributes.each { |attribute, value| value.each { |key, item| item['ProvisioningStyle'] = 'Manual' } if value.kind_of? Hash } } end configs = project.objects.select { |obj| obj.isa == 'XCBuildConfiguration' && obj.to_s == configuration && obj.build_settings[info_plist_key] } UI.user_error!("Info plist uses $(#{build_settings_key}), but xcodeproj does not") unless configs.count > 0 configs = configs.select do |obj| info_plist_value = obj.build_settings[info_plist_key] !map[info_plist_value].nil? end UI.user_error!("Xcodeproj doesn't have #{configuration} with info plist #{project_path}.") unless configs.count > 0 # For each of the build configurations, set specific profile configs.each do |c| info_plist_value = c.build_settings[info_plist_key] c.build_settings[build_settings_key] = map[info_plist_value] end project.save UI.success("Successfully updated project") end