Skip to content

Commit b9b6edf

Browse files
authored
Merge pull request #4 from jdee/target
Target parameter
2 parents 3939dbe + e74325b commit b9b6edf

File tree

12 files changed

+164
-80
lines changed

12 files changed

+164
-80
lines changed

.rubocop.yml

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,23 @@ Style/VariableNumber:
2323
Style/MethodMissing:
2424
Enabled: false
2525

26-
#
26+
#
2727
# File.chmod(0777, f)
28-
#
28+
#
2929
# is easier to read than
30-
#
30+
#
3131
# File.chmod(0o777, f)
32-
#
32+
#
3333
Style/NumericLiteralPrefix:
3434
Enabled: false
3535

36-
#
36+
#
3737
# command = (!clean_expired.nil? || !clean_pattern.nil?) ? CLEANUP : LIST
38-
#
38+
#
3939
# is easier to read than
40-
#
40+
#
4141
# command = !clean_expired.nil? || !clean_pattern.nil? ? CLEANUP : LIST
42-
#
42+
#
4343
Style/TernaryParentheses:
4444
Enabled: false
4545

@@ -200,3 +200,19 @@ Style/IfInsideElse:
200200
# Sometimes we just want to 'collect'
201201
Style/CollectionMethods:
202202
Enabled: false
203+
204+
# They have not to be snake_case
205+
Style/FileName:
206+
Exclude:
207+
- '*.gemspec'
208+
- '**/Dangerfile'
209+
- '**/Brewfile'
210+
- '**/Gemfile'
211+
- '**/Podfile'
212+
- '**/Rakefile'
213+
- '**/Fastfile'
214+
- '**/Deliverfile'
215+
- '**/Snapfile'
216+
217+
Eval:
218+
Enabled: false

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ source 'https://rubygems.org'
22

33
gemspec
44

5-
gem 'simplecov'
65
gem 'rspec-simplecov'
6+
gem 'simplecov'
77

88
plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile')
99
eval(File.read(plugins_path), binding) if File.exist?(plugins_path)

Gemfile.lock

Lines changed: 36 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,54 @@
11
PATH
22
remote: .
33
specs:
4-
fastlane-plugin-settings_bundle (1.0.1)
4+
fastlane-plugin-settings_bundle (1.1.0)
55
plist
66
xcodeproj (>= 1.4.0)
77

88
GEM
99
remote: https://rubygems.org/
1010
specs:
11-
CFPropertyList (2.3.4)
12-
activesupport (4.0.13)
13-
i18n (~> 0.6, >= 0.6.9)
14-
minitest (~> 4.2)
15-
multi_json (~> 1.3)
16-
thread_safe (~> 0.1)
17-
tzinfo (~> 0.3.37)
18-
addressable (2.5.0)
11+
CFPropertyList (2.3.5)
12+
addressable (2.5.1)
1913
public_suffix (~> 2.0, >= 2.0.2)
2014
ast (2.3.0)
2115
babosa (1.0.2)
2216
claide (1.0.1)
2317
coderay (1.1.1)
2418
colored (1.2)
25-
commander (4.4.3)
19+
colored2 (3.1.2)
20+
commander-fastlane (4.4.4)
2621
highline (~> 1.7.2)
27-
diff-lcs (1.2.5)
22+
diff-lcs (1.3)
2823
docile (1.1.5)
29-
domain_name (0.5.20161129)
24+
domain_name (0.5.20170404)
3025
unf (>= 0.0.5, < 1.0.0)
31-
dotenv (2.1.1)
32-
excon (0.54.0)
33-
faraday (0.10.0)
26+
dotenv (2.2.0)
27+
excon (0.55.0)
28+
faraday (0.12.0.1)
3429
multipart-post (>= 1.2, < 3)
3530
faraday-cookie_jar (0.0.6)
3631
faraday (>= 0.7.4)
3732
http-cookie (~> 1.0.0)
38-
faraday_middleware (0.10.1)
33+
faraday_middleware (0.11.0.1)
3934
faraday (>= 0.7.4, < 1.0)
40-
fastimage (2.0.1)
41-
addressable (~> 2)
42-
fastlane (2.3.1)
43-
activesupport (< 5)
35+
fastimage (2.1.0)
36+
fastlane (2.27.0)
4437
addressable (>= 2.3, < 3.0.0)
4538
babosa (>= 1.0.2, < 2.0.0)
46-
bundler (~> 1.12)
39+
bundler (>= 1.12.0, < 2.0.0)
4740
colored
48-
commander (>= 4.4.0, < 5.0.0)
41+
commander-fastlane (>= 4.4.0, < 5.0.0)
4942
dotenv (>= 2.1.1, < 3.0.0)
5043
excon (>= 0.45.0, < 1.0.0)
5144
faraday (~> 0.9)
5245
faraday-cookie_jar (~> 0.0.6)
5346
faraday_middleware (~> 0.9)
5447
fastimage (>= 1.6)
5548
gh_inspector (>= 1.0.1, < 2.0.0)
56-
google-api-client (~> 0.9.1)
49+
google-api-client (~> 0.9.2)
5750
highline (>= 1.7.2, < 2.0.0)
58-
json (>= 2.0.1, < 3.0.0)
51+
json (< 3.0.0)
5952
mini_magick (~> 4.5.1)
6053
multi_json
6154
multi_xml (~> 0.5)
@@ -66,12 +59,13 @@ GEM
6659
slack-notifier (>= 1.3, < 2.0.0)
6760
terminal-notifier (>= 1.6.2, < 2.0.0)
6861
terminal-table (>= 1.4.5, < 2.0.0)
62+
tty-screen (~> 0.5.0)
6963
word_wrap (~> 1.0.0)
70-
xcodeproj (>= 0.20, < 2.0.0)
64+
xcodeproj (>= 1.4.4, < 2.0.0)
7165
xcpretty (>= 0.2.4, < 1.0.0)
7266
xcpretty-travis-formatter (>= 0.0.3)
73-
gh_inspector (1.0.2)
74-
google-api-client (0.9.20)
67+
gh_inspector (1.0.3)
68+
google-api-client (0.9.28)
7569
addressable (~> 2.3)
7670
googleauth (~> 0.5)
7771
httpclient (~> 2.7)
@@ -93,11 +87,10 @@ GEM
9387
domain_name (~> 0.5)
9488
httpclient (2.8.3)
9589
hurley (0.2)
96-
i18n (0.7.0)
97-
json (2.0.2)
90+
json (2.1.0)
9891
jwt (1.5.6)
9992
little-plugger (1.1.4)
100-
logging (2.1.0)
93+
logging (2.2.2)
10194
little-plugger (~> 1.1)
10295
multi_json (~> 1.10)
10396
memoist (0.15.0)
@@ -106,21 +99,20 @@ GEM
10699
mime-types-data (~> 3.2015)
107100
mime-types-data (3.2016.0521)
108101
mini_magick (4.5.1)
109-
minitest (4.7.5)
110102
multi_json (1.12.1)
111103
multi_xml (0.6.0)
112104
multipart-post (2.0.0)
113105
nanaimo (0.2.3)
114106
os (0.9.6)
115-
parser (2.3.3.1)
107+
parser (2.4.0.0)
116108
ast (~> 2.2)
117109
plist (3.2.0)
118110
powerpack (0.1.1)
119111
pry (0.10.4)
120112
coderay (~> 1.1.0)
121113
method_source (~> 0.8.1)
122114
slop (~> 3.4)
123-
public_suffix (2.0.4)
115+
public_suffix (2.0.5)
124116
rainbow (2.2.1)
125117
rake (12.0.0)
126118
representable (2.3.0)
@@ -141,21 +133,21 @@ GEM
141133
rspec-support (~> 3.5.0)
142134
rspec-simplecov (0.2.2)
143135
rspec-support (3.5.0)
144-
rubocop (0.46.0)
145-
parser (>= 2.3.1.1, < 3.0)
136+
rubocop (0.48.1)
137+
parser (>= 2.3.3.1, < 3.0)
146138
powerpack (~> 0.1)
147139
rainbow (>= 1.99.1, < 3.0)
148140
ruby-progressbar (~> 1.7)
149141
unicode-display_width (~> 1.0, >= 1.0.1)
150142
ruby-progressbar (1.8.1)
151-
rubyzip (1.2.0)
143+
rubyzip (1.2.1)
152144
security (0.1.3)
153145
signet (0.7.3)
154146
addressable (~> 2.3)
155147
faraday (~> 0.9)
156148
jwt (~> 1.5)
157149
multi_json (~> 1.10)
158-
simplecov (0.12.0)
150+
simplecov (0.14.1)
159151
docile (~> 1.1.0)
160152
json (>= 1.8, < 3)
161153
simplecov-html (~> 0.10.0)
@@ -165,21 +157,19 @@ GEM
165157
terminal-notifier (1.7.1)
166158
terminal-table (1.7.3)
167159
unicode-display_width (~> 1.1.1)
168-
thread_safe (0.3.5)
169-
tzinfo (0.3.52)
160+
tty-screen (0.5.0)
170161
uber (0.0.15)
171162
unf (0.1.4)
172163
unf_ext
173-
unf_ext (0.0.7.2)
174-
unicode-display_width (1.1.2)
164+
unf_ext (0.0.7.4)
165+
unicode-display_width (1.1.3)
175166
word_wrap (1.0.0)
176-
xcodeproj (1.4.2)
167+
xcodeproj (1.4.4)
177168
CFPropertyList (~> 2.3.3)
178-
activesupport (>= 3)
179169
claide (>= 1.0.1, < 2.0)
180-
colored (~> 1.2)
170+
colored2 (~> 3.1)
181171
nanaimo (~> 0.2.3)
182-
xcpretty (0.2.4)
172+
xcpretty (0.2.6)
183173
rouge (~> 1.8)
184174
xcpretty-travis-formatter (0.0.4)
185175
xcpretty (~> 0.2, >= 0.0.7)
@@ -199,4 +189,4 @@ DEPENDENCIES
199189
simplecov
200190

201191
BUNDLED WITH
202-
1.13.7
192+
1.14.6

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,19 @@ update_settings_bundle(
8787
)
8888
```
8989

90+
#### Target parameter
91+
92+
By default, this action takes the settings from the first non-test, non-extension target in
93+
the project. Use the optional :target parameter to specify a target by name.
94+
```ruby
95+
update_settings_bundle(
96+
xcodeproj: "MyProject.xcodeproj",
97+
key: "CurrentAppVersion",
98+
value: ":version (:build)",
99+
target: "MyAppTarget"
100+
)
101+
```
102+
90103
## Example
91104

92105
See the SettingsBundleExample subdirectory for a sample project that

Rakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ RSpec::Core::RakeTask.new
66
require 'rubocop/rake_task'
77
RuboCop::RakeTask.new(:rubocop)
88

9-
task default: [:spec, :rubocop]
9+
task default: %i[spec rubocop]

circle.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,4 @@ test:
33
- bundle exec rake
44
machine:
55
ruby:
6-
version: 2.3.2
7-
# Enable xcode below if you need macOS
8-
# xcode:
9-
# version: "7.3"
6+
version: 2.4.0

fastlane-plugin-settings_bundle.gemspec

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
# coding: utf-8
2+
23
lib = File.expand_path("../lib", __FILE__)
34
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
45
require 'fastlane/plugin/settings_bundle/version'
56

67
Gem::Specification.new do |spec|
78
spec.name = 'fastlane-plugin-settings_bundle'
89
spec.version = Fastlane::SettingsBundle::VERSION
9-
spec.author = %q{Jimmy Dee}
10-
spec.email = %q{[email protected]}
10+
spec.author = 'Jimmy Dee'
11+
spec.email = '[email protected]'
1112

12-
spec.summary = %q{Fastlane plugin to update static settings in an iOS settings bundle}
13+
spec.summary = 'Fastlane plugin to update static settings in an iOS settings bundle'
1314
spec.homepage = "https://github.com/jdee/settings-bundle"
1415
spec.license = "MIT"
1516

16-
spec.files = Dir["lib/**/*"] + %w(README.md LICENSE)
17+
spec.files = Dir["lib/**/*"] + %w[README.md LICENSE]
1718
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
1819
spec.require_paths = ['lib']
1920

lib/fastlane/plugin/settings_bundle/actions/update_settings_bundle_action.rb

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class UpdateSettingsBundleAction < Action
2424
def self.run(params)
2525
key = params[:key]
2626
configuration = params[:configuration]
27+
target_name = params[:target]
2728
file = params[:file]
2829
value = params[:value]
2930

@@ -32,7 +33,7 @@ def self.run(params)
3233

3334
helper = Helper::SettingsBundleHelper
3435

35-
settings = helper.settings_from_project project, configuration
36+
settings = helper.settings_from_project project, configuration, target_name
3637

3738
formatted_value = helper.formatted_value value, settings
3839

@@ -89,6 +90,11 @@ def self.available_options
8990
description: "The plist file in the Settings.bundle to update",
9091
optional: true,
9192
default_value: "Root.plist",
93+
type: String),
94+
FastlaneCore::ConfigItem.new(key: :file,
95+
env_name: "SETTINGS_BUNDLE_TARGET",
96+
description: "An optional target name from the project",
97+
optional: true,
9298
type: String)
9399
]
94100
end
@@ -124,6 +130,14 @@ def self.example_code
124130
value: ":version (:build)",
125131
configuration: "Debug"
126132
)
133+
EOF,
134+
<<-EOF
135+
update_settings_bundle(
136+
xcodeproj: "MyProject.xcodeproj",
137+
key: "CurrentAppVersion",
138+
value: ":version (:build)",
139+
target: "MyAppTarget"
140+
)
127141
EOF
128142
]
129143
end

lib/fastlane/plugin/settings_bundle/helper/settings_bundle_helper.rb

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,17 @@ def formatted_value(value, settings)
4545
#
4646
# :project: An open Xcodeproj::Project via Xcodeproj::Project.open, e.g.
4747
# :configuration: A valid build configuration in the project
48-
def settings_from_project(project, configuration)
49-
# find the first non-test, non-extension target
50-
# TODO: Make this a :target parameter
51-
target = project.targets.find { |t| !t.test_target_type? && !t.extension_target_type? }
52-
raise "No application target found" if target.nil?
48+
# :target_name: A valid target name in the project or nil to use the first application target
49+
def settings_from_project(project, configuration, target_name)
50+
if target_name
51+
target = project.targets.find { |t| t.name == target_name }
52+
raise "Target named \"#{target_name}\" not found" if target.nil?
53+
else
54+
# find the first non-test, non-extension target
55+
# TODO: Make this a :target parameter
56+
target = project.targets.find { |t| !t.test_target_type? && !t.extension_target_type? }
57+
raise "No application target found" if target.nil?
58+
end
5359

5460
# find the Info.plist paths for all configurations
5561
info_plist_paths = target.resolved_build_setting "INFOPLIST_FILE"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module Fastlane
22
module SettingsBundle
3-
VERSION = "1.0.1"
3+
VERSION = "1.1.0"
44
end
55
end

0 commit comments

Comments
 (0)