fastlane-plugin-remove_setting 0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0bf78e6b0081cefb4d013f51a0cb3298c81ecbea
4
+ data.tar.gz: 14f782ca6bc6cc2a1cebf102d5d1b45ec9ffa3f8
5
+ SHA512:
6
+ metadata.gz: 28abdf1acfa6bb12729e265ced41644a1fd76640b9e55a4c8038c3b1cc457b89c4647e3f7176a0e6464b692c7b34a40a207cdcf2ff2db3880b293790b3f63a17
7
+ data.tar.gz: fc41bff39d27c21979064bbec22c669b46547ec2b2409457d9992a46b7394e2209ae94c27638fae1ff074f3db4d0c6e4cbb4a0c9545e5f292eeaa6fc21c80cd8
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Colin Harris <col.w.harris@gmail.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,121 @@
1
+ # remove_setting plugin
2
+
3
+ [![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg?style=flat-square)](https://rubygems.org/gems/fastlane-plugin-remove_setting)
4
+ [![Gem](https://img.shields.io/gem/v/fastlane-plugin-remove_setting.svg?style=flat)](https://rubygems.org/gems/fastlane-plugin-remove_setting)
5
+ [![Downloads](https://img.shields.io/gem/dt/fastlane-plugin-remove_setting.svg?style=flat)](https://rubygems.org/gems/fastlane-plugin-remove_setting)
6
+ [![License](https://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://github.com/col/fastlane-plugin-remove_setting/blob/master/LICENSE)
7
+ [![CircleCI](https://img.shields.io/circleci/project/github/col/remove_setting.svg)](https://circleci.com/gh/col/remove_setting)
8
+
9
+ ## Getting Started
10
+
11
+ This project is a [fastlane](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-remove_setting`, run the following command:
12
+ ```
13
+ fastlane add_plugin remove_setting
14
+ ```
15
+
16
+ ## About settings_bundle
17
+
18
+ Fastlane plugin to remove settings in an iOS settings bundle
19
+
20
+ ### remove_setting
21
+
22
+ This action removes a specified NSUserDefaults key in the project's
23
+ `Settings.bundle`.
24
+
25
+ ```ruby
26
+ remove_setting(
27
+ key: "DevelopmentMode"
28
+ )
29
+ ```
30
+
31
+ This removes the key named `DevelopmentMode` in the `Root.plist` in the
32
+ `Settings.bundle`.
33
+
34
+ #### Specifying the project file
35
+
36
+ By default, the action looks for a single .xcodeproj file in the repo,
37
+ excluding any under Pods. If more than one is present, use the `:xcodeproj`
38
+ parameter:
39
+
40
+ ```ruby
41
+ remove_setting(
42
+ xcodeproj: "./MyProject.xcodeproj",
43
+ key: "DevelopmentMode"
44
+ )
45
+ ```
46
+
47
+ #### Files other than Root.plist
48
+
49
+ ```ruby
50
+ remove_setting(
51
+ file: "About.plist",
52
+ key: "DevelopmentMode"
53
+ )
54
+ ```
55
+
56
+ The `file` argument specifies a file other than `Root.plist` in the
57
+ `Settings.bundle`. If you have multiple projects, keys or files,
58
+ run the action multiple times.
59
+
60
+ #### Bundle name parameter
61
+
62
+ By default, this action looks for a file called `Settings.bundle` in the project. To
63
+ specify a different name for your settings bundle, use the `:bundle_name` option:
64
+ ```ruby
65
+ remove_setting(
66
+ key: "DevelopmentMode",
67
+ bundle_name: "MySettings.bundle"
68
+ )
69
+ ```
70
+
71
+ Also see the [example app](./examples) and [example Fastfile](./fastlane/Fastfile) in the repo.
72
+
73
+ ## Examples
74
+
75
+ [RemoveSettingExample]: ./examples/RemoveSettingExample
76
+
77
+ ### RemoveSettingExample
78
+
79
+ See the `examples/RemoveSettingExample` subdirectory for a simple example project that
80
+ makes use of this action.
81
+
82
+ First build and run the sample project on a simulator or device. Tap 'Open Settings' to view the settings for RemoveSettingExample in the Settings app. You'll see the version number
83
+ as well as a development mode switch.
84
+
85
+ Now run Fastlane:
86
+
87
+ ```bash
88
+ bundle install
89
+ bundle exec fastlane test
90
+ ```
91
+
92
+ Run the sample app again. Tap 'Open Settings' again to see the updated settings. The development mode switch should no longer be visible.
93
+
94
+ ## Run tests for this plugin
95
+
96
+ To run both the tests, and code style validation, run
97
+
98
+ ```
99
+ rake
100
+ ```
101
+
102
+ To automatically fix many of the styling issues, use
103
+ ```
104
+ rubocop -a
105
+ ```
106
+
107
+ ## Issues and Feedback
108
+
109
+ For any other issues and feedback about this plugin, please submit it to this repository.
110
+
111
+ ## Troubleshooting
112
+
113
+ If you have trouble using plugins, check out the [Plugins Troubleshooting](https://github.com/fastlane/fastlane/blob/master/fastlane/docs/PluginsTroubleshooting.md) doc in the main `fastlane` repo.
114
+
115
+ ## Using `fastlane` Plugins
116
+
117
+ For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Plugins.md).
118
+
119
+ ## About `fastlane`
120
+
121
+ `fastlane` is the easiest way to automate beta deployments and releases for your iOS and Android apps. To learn more, check out [fastlane.tools](https://fastlane.tools).
@@ -0,0 +1,16 @@
1
+ require 'fastlane/plugin/remove_setting/version'
2
+
3
+ module Fastlane
4
+ module RemoveSetting
5
+ # Return all .rb files inside the "actions" and "helper" directory
6
+ def self.all_classes
7
+ Dir[File.expand_path('**/{actions,helper}/*.rb', File.dirname(__FILE__))]
8
+ end
9
+ end
10
+ end
11
+
12
+ # By default we want to import all available actions and helpers
13
+ # A plugin can contain any number of actions and plugins
14
+ Fastlane::RemoveSetting.all_classes.each do |current|
15
+ require current
16
+ end
@@ -0,0 +1,126 @@
1
+ # Copyright (c) 2016-17 Colin Harris
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the "Software"), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in
11
+ # all copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ # SOFTWARE.
20
+ require 'fastlane/plugin/settings_bundle'
21
+
22
+ module Fastlane
23
+ module Actions
24
+ class RemoveSettingAction < Action
25
+ def self.run(params)
26
+ key = params[:key]
27
+ file = params[:file]
28
+
29
+ bundleHelper = Fastlane::Helper::SettingsBundleHelper
30
+ helper = Helper::RemoveSettingHelper
31
+
32
+ xcodeproj_path = bundleHelper.xcodeproj_path_from_params params
33
+ # Error already reported in helper
34
+ return if xcodeproj_path.nil?
35
+
36
+ # try to open project file (raises)
37
+ project = Xcodeproj::Project.open xcodeproj_path
38
+
39
+ # raises
40
+ helper.remove_setting project, params[:bundle_name], file, key
41
+ rescue => e
42
+ UI.user_error! "#{e.message}\n#{e.backtrace}"
43
+ end
44
+
45
+ def self.description
46
+ 'Fastlane plugin action to remove settings in an iOS settings bundle'
47
+ end
48
+
49
+ def self.author
50
+ 'Colin Harris'
51
+ end
52
+
53
+ def self.details
54
+ "This action is used to automatically delete an entry \n" \
55
+ "in an app's Settings bundle. It can be used to remove settings \n." \
56
+ "that you do not want to make available in some environments."
57
+ end
58
+
59
+ def self.available_options
60
+ [
61
+ # Required parameters
62
+ FastlaneCore::ConfigItem.new(key: :key,
63
+ env_name: 'SETTINGS_BUNDLE_KEY',
64
+ description: 'The user defaults key to update in the settings bundle',
65
+ optional: false,
66
+ type: String),
67
+
68
+ # Optional parameters
69
+ FastlaneCore::ConfigItem.new(key: :xcodeproj,
70
+ env_name: 'SETTINGS_BUNDLE_XCODEPROJ',
71
+ description: 'An Xcode project file whose settings bundle to update',
72
+ optional: true,
73
+ type: String),
74
+ FastlaneCore::ConfigItem.new(key: :file,
75
+ env_name: 'SETTINGS_BUNDLE_FILE',
76
+ description: 'The plist file in the Settings.bundle to update',
77
+ optional: true,
78
+ default_value: 'Root.plist',
79
+ type: String),
80
+ FastlaneCore::ConfigItem.new(key: :bundle_name,
81
+ env_name: 'SETTINGS_BUNDLE_BUNDLE_NAME',
82
+ description: 'The name of the settings bundle in the project (default Settings.bundle)',
83
+ optional: true,
84
+ default_value: 'Settings.bundle',
85
+ type: String)
86
+ ]
87
+ end
88
+
89
+ def self.example_code
90
+ [
91
+ <<-EOF
92
+ remove_setting(
93
+ key: "ItemToRemove"
94
+ )
95
+ EOF,
96
+ <<-EOF
97
+ remove_setting(
98
+ xcodeproj: "MyProject.xcodeproj",
99
+ key: "ItemToRemove",
100
+ )
101
+ EOF,
102
+ <<-EOF
103
+ remove_setting(
104
+ file: "About.plist",
105
+ key: "ItemToRemove"
106
+ )
107
+ EOF,
108
+ <<-EOF
109
+ remove_setting(
110
+ key: "ItemToRemove",
111
+ bundle_name: "MySettings.bundle"
112
+ )
113
+ EOF
114
+ ]
115
+ end
116
+
117
+ def self.is_supported?(platform)
118
+ platform == :ios
119
+ end
120
+
121
+ def self.category
122
+ :project
123
+ end
124
+ end
125
+ end
126
+ end
@@ -0,0 +1,70 @@
1
+ # Copyright (c) 2016-17 Colin Harris
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the "Software"), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in
11
+ # all copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ # SOFTWARE.
20
+
21
+ require 'plist'
22
+
23
+ module Fastlane
24
+ module Helper
25
+ class RemoveSettingHelper
26
+ class << self
27
+ # Takes an open Xcodeproj::Project, extracts the settings bundle
28
+ # and removes the specified setting key in the specified file.
29
+ # Raises on error.
30
+ #
31
+ # :project: An open Xcodeproj::Project, obtained from Xcodeproj::Project.open, e.g.
32
+ # :bundle_name: (String) Regex to identify the bundle to look for, usually Settings.bundle.
33
+ # :file: A settings plist file in the Settings.bundle, usually "Root.plist"
34
+ # :key: A valid NSUserDefaults key in the Settings.bundle
35
+ def remove_setting(project, bundle_name, file, key)
36
+ settings_bundle = project.files.find { |f| f.path =~ /#{bundle_name}/ }
37
+
38
+ raise "#{bundle_name} not found in project" if settings_bundle.nil?
39
+
40
+ # The #real_path method returns the full resolved path to the Settings.bundle
41
+ settings_bundle_path = settings_bundle.real_path
42
+
43
+ plist_path = File.join settings_bundle_path, file
44
+
45
+ # raises IOError
46
+ settings_plist = File.open(plist_path) { |f| Plist.parse_xml f }
47
+
48
+ raise "Could not parse #{plist_path}" if settings_plist.nil?
49
+
50
+ preference_specifiers = settings_plist['PreferenceSpecifiers']
51
+ raise "#{file} is not a settings plist file" if preference_specifiers.nil?
52
+
53
+ original_count = preference_specifiers.length
54
+
55
+ raise "#{file} is not a settings plist file" if preference_specifiers.nil?
56
+
57
+ # Remove the specifier matching the supplied key
58
+ settings_plist['PreferenceSpecifiers'] = preference_specifiers.reject do |specifier|
59
+ specifier['Key'] == key
60
+ end
61
+
62
+ raise "preference specifier for key #{key} not found in #{file}" if settings_plist['PreferenceSpecifiers'].length == original_count
63
+
64
+ # Save (raises)
65
+ Plist::Emit.save_plist settings_plist, plist_path
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,5 @@
1
+ module Fastlane
2
+ module RemoveSetting
3
+ VERSION = '0.1'.freeze
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,175 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fastlane-plugin-remove_setting
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ platform: ruby
6
+ authors:
7
+ - Colin Harris
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-09-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: plist
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.3'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: xcodeproj
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.4'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.4'
41
+ - !ruby/object:Gem::Dependency
42
+ name: fastlane-plugin-settings_bundle
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '='
46
+ - !ruby/object:Gem::Version
47
+ version: 1.2.1
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: 1.2.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.10'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.10'
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.15'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.15'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.6'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.6'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rake
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '12.1'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '12.1'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '0.49'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '0.49'
125
+ - !ruby/object:Gem::Dependency
126
+ name: fastlane
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '2.55'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '2.55'
139
+ description:
140
+ email: col.w.harris@gmail.com
141
+ executables: []
142
+ extensions: []
143
+ extra_rdoc_files: []
144
+ files:
145
+ - LICENSE
146
+ - README.md
147
+ - lib/fastlane/plugin/remove_setting.rb
148
+ - lib/fastlane/plugin/remove_setting/actions/remove_setting_action.rb
149
+ - lib/fastlane/plugin/remove_setting/helper/remove_setting_helper.rb
150
+ - lib/fastlane/plugin/remove_setting/version.rb
151
+ homepage: https://github.com/col/fastlane-plugin-remove_setting
152
+ licenses:
153
+ - MIT
154
+ metadata: {}
155
+ post_install_message:
156
+ rdoc_options: []
157
+ require_paths:
158
+ - lib
159
+ required_ruby_version: !ruby/object:Gem::Requirement
160
+ requirements:
161
+ - - ">="
162
+ - !ruby/object:Gem::Version
163
+ version: '0'
164
+ required_rubygems_version: !ruby/object:Gem::Requirement
165
+ requirements:
166
+ - - ">="
167
+ - !ruby/object:Gem::Version
168
+ version: '0'
169
+ requirements: []
170
+ rubyforge_project:
171
+ rubygems_version: 2.6.8
172
+ signing_key:
173
+ specification_version: 4
174
+ summary: Fastlane plugin to remove settings from an iOS settings bundle
175
+ test_files: []