Class: Fastlane::Actions::UpdateUrlSchemesAction

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

Constant Summary

Constants inherited from Fastlane::Action

Fastlane::Action::AVAILABLE_CATEGORIES

Class Method Summary collapse

Methods inherited from Fastlane::Action

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

Class Method Details

.authorsObject



62
63
64
# File 'lib/fastlane/actions/update_url_schemes.rb', line 62

def self.authors
  ['kmikael']
end

.available_optionsObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/fastlane/actions/update_url_schemes.rb', line 19

def self.available_options
  [
    FastlaneCore::ConfigItem.new(
      key: :path,
      env_name: 'FL_UPDATE_URL_SCHEMES_PATH',
      description: 'The Plist file\'s path',
      is_string: true,
      optional: false,
      verify_block: proc do |path|
        UI.user_error!("Could not find plist at path '#{path}'") unless File.exist?(path)
      end
    ),

    FastlaneCore::ConfigItem.new(
      key: :url_schemes,
      env_name: "FL_UPDATE_URL_SCHEMES_SCHEMES",
      description: 'The new URL schemes',
      is_string: false,
      optional: false,
      verify_block: proc do |url_schemes|
        string = "The URL schemes must be an array of strings, got '#{url_schemes}'."
        UI.user_error!(string) unless url_schemes.kind_of?(Array)

        url_schemes.each do |url_scheme|
          UI.user_error!(string) unless url_scheme.kind_of?(String)
        end
      end
    )
  ]
end

.categoryObject



79
80
81
# File 'lib/fastlane/actions/update_url_schemes.rb', line 79

def self.category
  :project
end

.descriptionObject



15
16
17
# File 'lib/fastlane/actions/update_url_schemes.rb', line 15

def self.description
  'Updates the URL schemes in the given Info.plist'
end

.detailsObject



50
51
52
53
54
55
56
# File 'lib/fastlane/actions/update_url_schemes.rb', line 50

def self.details
  [
    "This action allows you to update the URL schemes of the app before building it.",
    "For example, you can use this to set a different url scheme for the alpha",
    "or beta version of the app."
  ].join("\n")
end

.example_codeObject



70
71
72
73
74
75
76
77
# File 'lib/fastlane/actions/update_url_schemes.rb', line 70

def self.example_code
  [
    'update_url_schemes(
      path: "path/to/Info.plist",
      url_schemes: ["com.myapp"]
    )'
  ]
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


66
67
68
# File 'lib/fastlane/actions/update_url_schemes.rb', line 66

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

.outputObject



58
59
60
# File 'lib/fastlane/actions/update_url_schemes.rb', line 58

def self.output
  []
end

.run(params) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/fastlane/actions/update_url_schemes.rb', line 6

def self.run(params)
  path = params[:path]
  url_schemes = params[:url_schemes]

  hash = Plist.parse_xml(path)
  hash['CFBundleURLTypes'].first['CFBundleURLSchemes'] = url_schemes
  File.write(path, hash.to_plist)
end