Class: Fastlane::Actions::PlistValueAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/rearchive/actions/plist_value_action.rb

Class Method Summary collapse

Class Method Details

.authorsObject



37
38
39
# File 'lib/fastlane/plugin/rearchive/actions/plist_value_action.rb', line 37

def self.authors
  ["naoigcat"]
end

.available_optionsObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/fastlane/plugin/rearchive/actions/plist_value_action.rb', line 41

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :archive_path,
                         description: "The path of the .ipa or .xcarchive to be modified",
                            optional: false,
                                type: String),

    FastlaneCore::ConfigItem.new(key: :plist_path,
                         description: "The name of the .plist file to modify, relative to the .app bundle",
                            optional: true,
                       default_value: "Info.plist",
                                type: String),

    FastlaneCore::ConfigItem.new(key: :plist_values,
                         description: "Hash of plist values to set to the plist file",
                            optional: false,
                                type: Hash)
  ]
end

.descriptionObject



33
34
35
# File 'lib/fastlane/plugin/rearchive/actions/plist_value_action.rb', line 33

def self.description
  "Overwrite values of .plists inside .ipa/.xcarchive"
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


61
62
63
# File 'lib/fastlane/plugin/rearchive/actions/plist_value_action.rb', line 61

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

.run(params) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/fastlane/plugin/rearchive/actions/plist_value_action.rb', line 10

def self.run(params)
  archive_path = File.expand_path(params[:archive_path])
  raise "Archive path #{archive_path} does not exist" unless File.exist?(archive_path)

  if File.directory?(archive_path)
    archive = RearchiveHelper::XCArchive.new(archive_path)
  else
    archive = RearchiveHelper::IPAArchive.new(archive_path)
  end
  if params[:plist_path]
    plist_path = archive.app_path(params[:plist_path])
  else
    plist_path = archive.app_path("Info.plist")
  end
  FastlaneCore::UI.message("Patching Plist: #{plist_path}")
  archive.extract(plist_path)
  plist_buddy = RearchiveHelper::PlistBuddy.new(archive.local_path(plist_path))
  params[:plist_values].each do |key, value|
    plist_buddy.exec("Set #{key} #{value}")
  end
  archive.replace(plist_path)
end