Class: Fastlane::Actions::SetInfoPlistValueAction

Inherits:
Fastlane::Action show all
Defined in:
lib/fastlane/actions/set_info_plist_value.rb

Constant Summary

Constants inherited from Fastlane::Action

Fastlane::Action::AVAILABLE_CATEGORIES

Class Method Summary collapse

Methods inherited from Fastlane::Action

action_name, author, details, lane_context, method_missing, other_action, output, return_value, sample_return_value, sh, step_text

Class Method Details

.authorsObject



49
50
51
# File 'lib/fastlane/actions/set_info_plist_value.rb', line 49

def self.authors
  ["kohtenko"]
end

.available_optionsObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/fastlane/actions/set_info_plist_value.rb', line 28

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :key,
                                 env_name: "FL_SET_INFO_PLIST_PARAM_NAME",
                                 description: "Name of key in plist",
                                 optional: false),
    FastlaneCore::ConfigItem.new(key: :value,
                                 env_name: "FL_SET_INFO_PLIST_PARAM_VALUE",
                                 description: "Value to setup",
                                 is_string: false,
                                 optional: false),
    FastlaneCore::ConfigItem.new(key: :path,
                                 env_name: "FL_SET_INFO_PLIST_PATH",
                                 description: "Path to plist file you want to update",
                                 optional: false,
                                 verify_block: proc do |value|
                                   UI.user_error!("Couldn't find plist file at path '#{value}'") unless File.exist?(value)
                                 end)
  ]
end

.categoryObject



63
64
65
# File 'lib/fastlane/actions/set_info_plist_value.rb', line 63

def self.category
  :project
end

.descriptionObject



24
25
26
# File 'lib/fastlane/actions/set_info_plist_value.rb', line 24

def self.description
  "Sets value to Info.plist of your project as native Ruby data structures"
end

.example_codeObject



57
58
59
60
61
# File 'lib/fastlane/actions/set_info_plist_value.rb', line 57

def self.example_code
  [
    'set_info_plist_value(path: "./Info.plist", key: "CFBundleIdentifier", value: "com.krausefx.app.beta")'
  ]
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/fastlane/actions/set_info_plist_value.rb', line 53

def self.is_supported?(platform)
  [:ios, :mac].include? platform
end

.run(params) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/fastlane/actions/set_info_plist_value.rb', line 7

def self.run(params)
  require "plist"

  begin
    path = File.expand_path(params[:path])
    plist = Plist.parse_xml(path)
    plist[params[:key]] = params[:value]
    new_plist = plist.to_plist
    File.write(path, new_plist)

    return params[:value]
  rescue => ex
    UI.error(ex)
    UI.error("Unable to set value to plist file at '#{path}'")
  end
end