Class: Fastlane::Actions::UpdateInfoPlistAction
- Inherits:
-
Fastlane::Action
- Object
- Fastlane::Action
- Fastlane::Actions::UpdateInfoPlistAction
- Defined in:
- lib/fastlane/actions/update_info_plist.rb
Documentation collapse
- .author ⇒ Object
- .available_options ⇒ Object
- .description ⇒ Object
- .is_supported?(platform) ⇒ Boolean
Class Method Summary collapse
Methods inherited from Fastlane::Action
action_name, authors, details, method_missing, other_action, output, return_value, sh, step_text
Class Method Details
.author ⇒ Object
88 89 90 |
# File 'lib/fastlane/actions/update_info_plist.rb', line 88 def self. 'tobiasstrebitzer' end |
.available_options ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/fastlane/actions/update_info_plist.rb', line 54 def self. [ FastlaneCore::ConfigItem.new(key: :xcodeproj, env_name: "FL_UPDATE_PLIST_PROJECT_PATH", description: "Path to your Xcode project", optional: true, verify_block: proc do |value| UI.user_error!("Please pass the path to the project, not the workspace") if value.end_with? ".xcworkspace" UI.user_error!("Could not find Xcode project") unless File.exist?(value) end), FastlaneCore::ConfigItem.new(key: :plist_path, env_name: "FL_UPDATE_PLIST_PATH", description: "Path to info plist", verify_block: proc do |value| UI.user_error!("Invalid plist file") unless value[-6..-1].casecmp(".plist").zero? end), FastlaneCore::ConfigItem.new(key: :app_identifier, env_name: 'FL_UPDATE_PLIST_APP_IDENTIFIER', description: 'The App Identifier of your app', default_value: ENV['PRODUCE_APP_IDENTIFIER'], optional: true), FastlaneCore::ConfigItem.new(key: :display_name, env_name: 'FL_UPDATE_PLIST_DISPLAY_NAME', description: 'The Display Name of your app', optional: true), FastlaneCore::ConfigItem.new(key: :block, is_string: false, description: 'A block to process plist with custom logic', optional: true) ] end |
.description ⇒ Object
50 51 52 |
# File 'lib/fastlane/actions/update_info_plist.rb', line 50 def self.description 'Update a Info.plist file with bundle identifier and display name' end |
.is_supported?(platform) ⇒ Boolean
46 47 48 |
# File 'lib/fastlane/actions/update_info_plist.rb', line 46 def self.is_supported?(platform) [:ios].include?(platform) end |
.run(params) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/fastlane/actions/update_info_plist.rb', line 7 def self.run(params) require 'plist' # Check if parameters are set if params[:app_identifier] or params[:display_name] or params[:block] if (params[:app_identifier] or params[:display_name]) and params[:block] UI.important("block parameter can not be specified with app_identifier or display_name") return false end # Assign folder from parameter or search for xcodeproj file folder = params[:xcodeproj] || Dir["*.xcodeproj"].first # Read existing plist file info_plist_path = File.join(folder, "..", params[:plist_path]) UI.user_error!("Couldn't find info plist file at path '#{params[:plist_path]}'") unless File.exist?(info_plist_path) plist = Plist.parse_xml(info_plist_path) # Update plist values plist['CFBundleIdentifier'] = params[:app_identifier] if params[:app_identifier] plist['CFBundleDisplayName'] = params[:display_name] if params[:display_name] params[:block].call(plist) if params[:block] # Write changes to file plist_string = Plist::Emit.dump(plist) File.write(info_plist_path, plist_string) UI.success("Updated #{params[:plist_path]} 💾.") plist_string else UI.important("You haven't specified any parameters to update your plist.") false end end |