update_plist

Update a plist file

This action allows you to modify any value inside any plist file.

update_plist
Supported platforms ios
Author @rishabhtayal, @matthiaszarzecki

6 Examples

update_plist( # Updates the CLIENT_ID and GOOGLE_APP_ID string entries in the plist-file
  plist_path: "path/to/your_plist_file.plist",
  block: proc do |plist|
    plist[:CLIENT_ID] = "new_client_id"
    plist[:GOOGLE_APP_ID] = "new_google_app_id"
  end
)
update_plist( # Sets a boolean entry
  plist_path: "path/to/your_plist_file.plist",
  block: proc do |plist|
    plist[:boolean_entry] = true
  end
)
update_plist( # Sets a number entry
  plist_path: "path/to/your_plist_file.plist",
  block: proc do |plist|
    plist[:number_entry] = 13
  end
)
update_plist( # Sets an array-entry with multiple sub-types
  plist_path: "path/to/your_plist_file.plist",
  block: proc do |plist|
    plist[:array_entry] = ["entry_01", true, 1243]
  end
)
update_plist( # The block can contain logic too
  plist_path: "path/to/your_plist_file.plist",
  block: proc do |plist|
    if options[:environment] == "production"
      plist[:CLIENT_ID] = "new_client_id_production"
    else
      plist[:CLIENT_ID] = "new_client_id_development"
    end
  end
)
update_plist( # Advanced processing: find URL scheme for particular key and replace value
  plist_path: "path/to/Info.plist",
  block: proc do |plist|
    urlScheme = plist["CFBundleURLTypes"].find{|scheme| scheme["CFBundleURLName"] == "com.acme.default-url-handler"}
    urlScheme[:CFBundleURLSchemes] = ["acme-production"]
  end
)

Parameters

Key Description Default
plist_path Path to plist file
block A block to process plist with custom logic

* = default value is dependent on the user's system


Documentation

To show the documentation in your terminal, run

fastlane action update_plist

CLI

It is recommended to add the above action into your Fastfile, however sometimes you might want to run one-offs. To do so, you can run the following command from your terminal

fastlane run update_plist

To pass parameters, make use of the : symbol, for example

fastlane run update_plist parameter1:"value1" parameter2:"value2"

It's important to note that the CLI supports primitive types like integers, floats, booleans, and strings. Arrays can be passed as a comma delimited string (e.g. param:"1,2,3"). Hashes are not currently supported.

It is recommended to add all fastlane actions you use to your Fastfile.


Source code

This action, just like the rest of fastlane, is fully open source, view the source code on GitHub


Back to actions