Class: Fastlane::Actions::RemoveSettingAction

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

Class Method Summary collapse

Class Method Details

.authorObject



49
50
51
# File 'lib/fastlane/plugin/remove_setting/actions/remove_setting_action.rb', line 49

def self.author
  'Colin Harris'
end

.available_optionsObject



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
87
# File 'lib/fastlane/plugin/remove_setting/actions/remove_setting_action.rb', line 59

def self.available_options
  [
    # Required parameters
    FastlaneCore::ConfigItem.new(key: :key,
                                 env_name: 'SETTINGS_BUNDLE_KEY',
                                 description: 'The user defaults key to update in the settings bundle',
                                 optional: false,
                                 type: String),

    # Optional parameters
    FastlaneCore::ConfigItem.new(key: :xcodeproj,
                                 env_name: 'SETTINGS_BUNDLE_XCODEPROJ',
                                 description: 'An Xcode project file whose settings bundle to update',
                                 optional: true,
                                 type: String),
    FastlaneCore::ConfigItem.new(key: :file,
                                 env_name: 'SETTINGS_BUNDLE_FILE',
                                 description: 'The plist file in the Settings.bundle to update',
                                 optional: true,
                                 default_value: 'Root.plist',
                                 type: String),
    FastlaneCore::ConfigItem.new(key: :bundle_name,
                                 env_name: 'SETTINGS_BUNDLE_BUNDLE_NAME',
                                 description: 'The name of the settings bundle in the project (default Settings.bundle)',
                                 optional: true,
                                 default_value: 'Settings.bundle',
                                 type: String)
  ]
end

.categoryObject



121
122
123
# File 'lib/fastlane/plugin/remove_setting/actions/remove_setting_action.rb', line 121

def self.category
  :project
end

.descriptionObject



45
46
47
# File 'lib/fastlane/plugin/remove_setting/actions/remove_setting_action.rb', line 45

def self.description
  'Fastlane plugin action to remove settings in an iOS settings bundle'
end

.detailsObject



53
54
55
56
57
# File 'lib/fastlane/plugin/remove_setting/actions/remove_setting_action.rb', line 53

def self.details
  "This action is used to automatically delete an entry \n" \
    "in an app's Settings bundle. It can be used to remove settings \n." \
    "that you do not want to make available in some environments."
end

.example_codeObject



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/fastlane/plugin/remove_setting/actions/remove_setting_action.rb', line 89

def self.example_code
  [
    <<-EOF
      remove_setting(
        key: "ItemToRemove"
      )
    EOF,
    <<-EOF
      remove_setting(
        xcodeproj: "MyProject.xcodeproj",
        key: "ItemToRemove",
      )
    EOF,
    <<-EOF
      remove_setting(
        file: "About.plist",
        key: "ItemToRemove"
      )
    EOF,
    <<-EOF
      remove_setting(
        key: "ItemToRemove",
        bundle_name: "MySettings.bundle"
      )
    EOF
  ]
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


117
118
119
# File 'lib/fastlane/plugin/remove_setting/actions/remove_setting_action.rb', line 117

def self.is_supported?(platform)
  platform == :ios
end

.run(params) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/fastlane/plugin/remove_setting/actions/remove_setting_action.rb', line 25

def self.run(params)
  key = params[:key]
  file = params[:file]

  bundleHelper = Fastlane::Helper::SettingsBundleHelper
  helper = Helper::RemoveSettingHelper

  xcodeproj_path = bundleHelper.xcodeproj_path_from_params params
  # Error already reported in helper
  return if xcodeproj_path.nil?

  # try to open project file (raises)
  project = Xcodeproj::Project.open xcodeproj_path

  # raises
  helper.remove_setting project, params[:bundle_name], file, key
rescue => e
  UI.user_error! "#{e.message}\n#{e.backtrace}"
end