-
Notifications
You must be signed in to change notification settings - Fork 0
/
Fastfile
246 lines (159 loc) · 6.97 KB
/
Fastfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
49
50
51
52
53
54
55
56
57
58
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
88
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
# Customise this file, documentation can be found here:
# https://github.com/KrauseFx/fastlane/tree/master/docs
# All available actions: https://github.com/KrauseFx/fastlane/blob/master/docs/Actions.md
# can also be listed using the `fastlane actions` command
# Change the syntax highlighting to Ruby
# All lines starting with a # are ignored when running `fastlane`
# More information about multiple platforms in fastlane: https://github.com/KrauseFx/fastlane/blob/master/docs/Platforms.md
# All available actions: https://github.com/KrauseFx/fastlane/blob/master/docs/Actions.md
# By default, fastlane will send which actions are used
# No personal data is shared, more information on https://github.com/fastlane/enhancer
# Uncomment the following line to opt out
# opt_out_usage
# If you want to automatically update fastlane if a new version is available:
# update_fastlane
# This is the minimum version number required.
# Update this, if you use features of a newer version
fastlane_version '2.100.0'
lane :beforeRelease do
ensure_git_branch(
branch: '(release/*|hotfix/*)'
)
ensure_git_status_clean
# === Read current version number
versionNumber = version_get_podspec(
path: 'Project.spec'
)
puts 'Current VERSION number: ' + versionNumber
# === Infer new version number
defaultNewVersion = git_branch.split('/').last
# === Define new version & build number
useInferredNEWVersionNumber = prompt(
text: 'Proceed with inferred NEW version number (' + defaultNewVersion + ')?',
boolean: true
)
if useInferredNEWVersionNumber
newVersionNumber = defaultNewVersion
else
newVersionNumber = prompt(
text: 'New VERSION number:'
)
end
newBuildNumber = number_of_commits.to_s
# === Apply NEW version & build number
increment_version_number(
xcodeproj: 'AppTemplate.xcodeproj',
version_number: newVersionNumber
)
increment_build_number(
xcodeproj: 'AppTemplate.xcodeproj',
build_number: newBuildNumber
)
version_bump_podspec(
path: 'Project.spec',
version_number: newVersionNumber
)
version_bump_podspec(
path: 'MobileViews.podspec',
version_number: newVersionNumber
)
version_bump_podspec(
path: 'ViewModels.podspec',
version_number: newVersionNumber
)
version_bump_podspec(
path: 'Models.podspec',
version_number: newVersionNumber
)
version_bump_podspec(
path: 'Services.podspec',
version_number: newVersionNumber
)
# ===
commit_version_bump(
message: 'Version Bump to ' + newVersionNumber + ' (' + newBuildNumber + ')',
xcodeproj: 'AppTemplate.xcodeproj',
include: ["Project.spec", "MobileViews.podspec", "ViewModels.podspec", "Models.podspec", "Services.podspec"]
)
end # lane :beforeRelease
lane :reconfigureProject do
# === Re-integrate dependencies
# default initial location for any command
# is inside 'Fastlane' folder
sh 'cd ./.. && bundle exec pod install'
# === Sort all project entries
# default initial location for any command
# is inside 'Fastlane' folder
sh 'cd ./.. && bundle exec xcodeproj sort "AppTemplate.xcodeproj"'
# === Build Phase Script - SwiftLint | 'AppTemplateMobile' | ../AppTemplate.xcodeproj
begin
project = Xcodeproj::Project.open("../AppTemplate.xcodeproj")
rescue => ex
# https://github.com/fastlane/fastlane/issues/7944#issuecomment-274232674
UI.error ex
UI.error("Failed to add Build Phase Script - SwiftLint | 'AppTemplateMobile' | ../AppTemplate.xcodeproj")
end
project
.targets
.select{ |t| ['AppTemplateMobile'].include?(t.name) }
.each{ |t|
thePhase = t.shell_script_build_phases.find { |s| s.name == "SwiftLint" }
unless thePhase.nil?
t.build_phases.delete(thePhase)
end
thePhase = t.new_shell_script_build_phase("SwiftLint")
thePhase.shell_script = '"Pods/SwiftLint/swiftlint" --path "${SRCROOT}/Sources/AppTemplateMobile"'
# thePhase.run_only_for_deployment_postprocessing = ...
t.build_phases.unshift(t.build_phases.delete(thePhase)) # move to top
}
project.save()
UI.success("Added Build Phase Script - SwiftLint | 'AppTemplateMobile' | ../AppTemplate.xcodeproj")
# === Build Settings | ../AppTemplate.xcodeproj
begin
project = Xcodeproj::Project.open("../AppTemplate.xcodeproj")
rescue => ex
# https://github.com/fastlane/fastlane/issues/7944#issuecomment-274232674
UI.error ex
UI.error("Failed to set Build Settings - ../AppTemplate.xcodeproj")
end
project.build_configurations.each do |config|
config.build_settings['ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES'] = 'YES'
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0'
config.build_settings['LD_RUNPATH_SEARCH_PATHS'] = '$(FRAMEWORK_SEARCH_PATHS) $(BUILT_PRODUCTS_DIR)'
config.build_settings['SWIFT_VERSION'] = '5.2'
config.build_settings['TARGETED_DEVICE_FAMILY'] = '1'
end # project.build_configurations.each
project.save()
UI.success("Set Build Settings - ../AppTemplate.xcodeproj")
# === Build Settings | AppTemplateMobile | ../AppTemplate.xcodeproj
begin
project = Xcodeproj::Project.open("../AppTemplate.xcodeproj")
rescue => ex
# https://github.com/fastlane/fastlane/issues/7944#issuecomment-274232674
UI.error ex
UI.error("Failed to set Build Settings - AppTemplateMobile | ../AppTemplate.xcodeproj")
end
begin
target = project.targets.find { |e| e.name == "AppTemplateMobile" }
raise RuntimeError, 'Target AppTemplateMobile is not found' if target.nil?
rescue => ex
# https://github.com/fastlane/fastlane/issues/7944#issuecomment-274232674
UI.error ex
UI.error("Failed to set Build Settings - AppTemplateMobile | ../AppTemplate.xcodeproj")
end
target.build_configurations.each do |config|
config.build_settings['CODE_SIGN_STYLE'] = 'Manual'
config.build_settings['INFOPLIST_FILE'] = 'Info/AppTemplateMobile.plist'
config.build_settings['PRODUCT_NAME'] = 'AppTemplateAppTemplateMobile'
if config.name == "Release"
config.build_settings['CODE_SIGN_IDENTITY'] = 'iPhone Distribution'
config.build_settings['PROVISIONING_PROFILE_SPECIFIER'] = 'AppTemplate-AdHoc'
end # config.name == "Release"
if config.name == "Debug"
config.build_settings['CODE_SIGN_IDENTITY'] = 'iPhone Developer'
config.build_settings['PROVISIONING_PROFILE_SPECIFIER'] = 'AppTemplate-Dev'
end # config.name == "Debug"
end # target.build_configurations.each
project.save()
UI.success("Set Build Settings - AppTemplateMobile | ../AppTemplate.xcodeproj")
end # lane :reconfigureProject