Skip to content

Commit f08bacc

Browse files
authored
Merge pull request #37 from surfstudio/bug_fixes
Improvements
2 parents 7e668e6 + a1759df commit f08bacc

File tree

17 files changed

+372
-424
lines changed

17 files changed

+372
-424
lines changed

README.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,13 @@ Xcode 8 or later.
1111
## List of templates
1212
* ### Surf MVP Application
1313
#### Features
14-
* Adds ModuleTransitionable.swift file to project
15-
* Adds Podfile with Fabric, Crashlytics, SwiftLint and SwiftGen pods
14+
* Adds Podfile with SwiftLint and SwiftGen pods
1615
* Adds .swiftlint.yml file and SwiftLint Run Script to Build phases
16+
* Adds .swiftgen.yml file and SwiftGen Run Script to Build phases
1717
* Adds Gemfile with fastlane, cocoapods, synx and generamba gems
1818
* Creates Fastlane files with template methods
1919
* Creates Rambafile with surf_mvp_module template and paths to project target and tests target
2020
* Creates Makefile with helper methods
21-
#### Options
22-
* Storyboards - creates Main.storyboard file
23-
* Alamofire - adds Alamofire, AlamofireImage and AlamofireNetworkActivityIndicator pods
2421

2522
## Installation
2623
To install or update the templates you need:
@@ -49,7 +46,7 @@ After that:
4946
3. Call `make synx`
5047
### Remove unnecessary files
5148
1. Open up the .xcodeproj file
52-
2. Remove the Non-iOS Resources folder from the Xcode project by selecting that folder in the sidebar, right clicking, then selecting delete from the menu, then selecting "Remove References" in the dialog that pops up
49+
2. Open Build Phases of your target, remove unecessary files from Compile Sources and Copy Bundle Resources
5350
### Insert keys in Fastlane files
5451
1. Open fastlane folder
5552
2. Insert `team_id` in AppFile
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,18 @@
1+
platform :ios, '10.0'
12

3+
inhibit_all_warnings!
4+
5+
def utils
6+
pod 'SwiftGen', '~> 6.1.0'
7+
pod 'SwiftLint', '~> 0.30.1'
8+
end
9+
10+
def common_pods
11+
utils
12+
# Put your pods here
13+
end
14+
15+
target '___PACKAGENAME___' do
16+
use_frameworks!
17+
common_pods
18+
end

Surf Base Application.xctemplate/TemplateInfo.plist

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@
282282
<string>../.gitignore</string>
283283
<string>Third Party/.gitkeep</string>
284284
<string>Services/.gitkeep</string>
285-
<string>Screens/.gitkeep</string>
285+
<string>User Stories/.gitkeep</string>
286286
<string>Resources/Strings/.gitkeep</string>
287287
<string>Resources/Images/.gitkeep</string>
288288
<string>Resources/Constants/.gitkeep</string>
@@ -312,34 +312,8 @@
312312
</dict>
313313
<key>../Podfile</key>
314314
<dict>
315-
<key>TargetIndices</key>
316-
<array/>
317-
<key>Beginning</key>
318-
<string>platform :ios, &apos;10.0&apos;
319-
320-
inhibit_all_warnings!
321-
322-
def utils
323-
pod 'SwiftGen', '~> 5.2.1'
324-
pod 'SwiftLint', '~> 0.25.0'
325-
end
326-
327-
target &apos;___PACKAGENAME___&apos; do
328-
329-
use_frameworks!
330-
331-
utils
332-
</string>
333-
<key>End</key>
334-
<string>
335-
336-
target &apos;___PACKAGENAME___Tests&apos; do
337-
# Put pods used for both test targets here
338-
end
339-
340-
end
341-
342-
</string>
315+
<key>Path</key>
316+
<string>Podfile</string>
343317
<key>Group</key>
344318
<array>
345319
<string>Non-iOS Resources</string>
@@ -484,10 +458,10 @@ end
484458
<key>TargetIndices</key>
485459
<array/>
486460
</dict>
487-
<key>Screens/.gitkeep</key>
461+
<key>User Stories/.gitkeep</key>
488462
<dict>
489463
<key>Group</key>
490-
<string>Screens</string>
464+
<string>User Stories</string>
491465
<key>Path</key>
492466
<string>../.gitkeep</string>
493467
<key>TargetIndices</key>

Surf Base Application.xctemplate/fastlane/Fastfile

Lines changed: 105 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@
99
# If you want to automatically update fastlane if a new version is available:
1010
# update_fastlane
1111

12-
# This is the minimum version number required.
13-
# Update this, if you use features of a newer version
14-
fastlane_version "2.58.0"
15-
1612
default_platform :ios
1713

1814
platform :ios do
@@ -26,6 +22,10 @@ platform :ios do
2622
# ensure_git_status_clean
2723
end
2824

25+
desc "Build Main scheme of Xcode target in Debug configuration"
26+
desc "Parameters:
27+
- clean: Pass **true** if you need to clean project before build
28+
"
2929
lane :build do |options|
3030
sigh(
3131
development: true,
@@ -42,18 +42,24 @@ platform :ios do
4242
)
4343
end
4444

45+
desc "Update build number, set tag and push version bump commit to the develop branch if needed"
46+
desc "Parameters:
47+
- version_number: Number of version that will be set
48+
- type: Type of the build which will be set with the tag. For Example: for release candidate builds with tag `1.0.0-rc10` you need to pass `rc`.
49+
- type_v: Version of current build type (type parameter).
50+
- skip_push: Pass **true** if you need to skip push commits to the repository. The default is **false**
51+
"
4552
lane :prepare_for_integration do |options|
46-
4753
version_number = options[:version_number]
4854
if version_number.nil?
4955
throw "Required version_number parameter"
5056
end
5157

5258
build_number = options[:type_v]
5359
if not build_number.nil?
54-
increment_build_number(build_number: build_number)
60+
increment_build_number_in_plist(build_number: build_number)
5561
else
56-
increment_build_number()
62+
increment_build_number_in_plist()
5763
end
5864

5965
increment_version_number(version_number: options[:version_number])
@@ -63,7 +69,7 @@ platform :ios do
6369
force: true
6470
)
6571

66-
tag_label = get_version_number
72+
tag_label = get_version_number_from_plist()
6773

6874
type = options[:type]
6975
typeIndex = options[:type_v]
@@ -75,45 +81,87 @@ platform :ios do
7581
tag: tag_label
7682
)
7783

78-
# sh("git push && git push origin --tags")
84+
skip_push_opt = options[:skip_push]
85+
needs_to_push = skip_push_opt.to_s.empty? || skip_push_opt.to_s == "false"
86+
87+
if needs_to_push
88+
sh("git push", error_callback: ->(result) {
89+
UI.error "git push failed with result: #{result}"
90+
})
91+
sh("git push origin --tags")
92+
end
7993
end
8094

81-
desc "Set build number and push version bump commit to develop branch with tag"
95+
desc "Update build number, set tag and push version bump commit to the develop branch if needed"
96+
desc "Parameters:
97+
- type: Type of the build which will be set with the tag. For Example: for release candidate builds with tag `1.0.0-rc10` you need to pass `rc`.
98+
- skip_push: Pass **true** if you need to skip push commits to the repository. The default is **false**
99+
"
82100
lane :prepare_for_beta do |options|
83-
84-
current_version = get_version_number
101+
current_version = get_version_number_from_plist
85102
type = options[:type]
86-
tag_prefix = 'dev_' + current_version + "-" + type
87-
88-
last_tag = git_tags
89-
.select{ |tag| tag.index(tag_prefix) == 0}
90-
.first
91-
92-
if last_tag.nil?
93-
last_tag_index = 0
94-
else
95-
last_tag_index = (last_tag.sub! tag_prefix, "").to_i
96-
end
103+
tag_prefix = current_version + "-" + type
97104

98-
result_tag_index = last_tag_index + 1
105+
last_tag_index = get_build_number_from_plist()
106+
result_tag_index = last_tag_index.to_i + 1
99107
build_number = tag_prefix + result_tag_index.to_s
100108

101109
prepare_for_integration(
102110
version_number: current_version,
103111
type: options[:type],
104112
type_v: result_tag_index.to_s,
105-
build_number: build_number
113+
build_number: build_number,
114+
skip_push: options[:skip_push]
106115
)
107116
end
108117

109-
desc "Set version and build numbers and push version bump commit to master branch with tag"
118+
desc "Set `rc` tag and push to the current branch"
119+
desc "Parameters:
120+
- include_beta: Pass **true** to call `prepare_for_beta` lane for debug and prod types
121+
- skip_push: Pass **true** if you need to skip push commits to the repository. The default is **false**
122+
"
110123
lane :prepare_for_release do |options|
111-
release_build_number = app_store_build_number.to_i + 1
112-
prepare_for_integration(version_number: options[:version_number], build_number: release_build_number)
124+
include_beta = options[:include_beta]
125+
if include_beta.nil? || include_beta.to_s == ""
126+
throw "Required include_beta parameter"
127+
end
128+
129+
if include_beta.to_s == "true"
130+
prepare_for_beta type:"debug"
131+
end
132+
133+
tag_label = get_version_number_from_plist(target: prod_target)
134+
135+
type = "rc"
136+
last_tag_index = get_build_number_from_plist(target: prod_target)
137+
138+
if not type.nil?
139+
tag_label = tag_label + "-" + type + "" + last_tag_index
140+
end
141+
142+
add_git_tag(
143+
tag: tag_label
144+
)
145+
146+
skip_push_opt = options[:skip_push]
147+
needs_to_push = skip_push_opt.to_s.empty? || skip_push_opt.to_s == "false"
148+
149+
if needs_to_push
150+
sh("git push", error_callback: ->(result) {
151+
UI.error "git push failed with result: #{result}"
152+
})
153+
sh("git push origin --tags")
154+
end
113155
end
114156

115-
desc "Submit a new Beta Build to Fabric"
116-
lane :beta do
157+
desc "Upload a new Beta Build to Fabric"
158+
desc "Parameters:
159+
- destination: Type of the build which will be submitted
160+
"
161+
lane :beta do |options|
162+
type = options[:destination]
163+
bundle_id = bundle_name
164+
scheme = main_scheme
117165

118166
cocoapods(use_bundle_exec:true)
119167

@@ -123,23 +171,24 @@ platform :ios do
123171
)
124172

125173
gym(
126-
scheme: main_scheme,
174+
scheme: scheme,
127175
configuration: "Debug",
128176
clean: true,
129177
include_bitcode: false,
130-
export_options: { compileBitcode: false},
131-
export_method: "development"
178+
export_options: {
179+
compileBitcode: false,
180+
},
181+
export_method: "development",
132182
)
133183

134184
upload_to_fabric
135185

136186
sh("rm ../*.mobileprovision")
137187
end
138188

139-
# Need check
140-
desc "Submit a new Release Build to Fabric"
189+
desc "Upload a new Release Build to iTunesConnect"
141190
lane :release do
142-
#cocoapods(use_bundle_exec: false)
191+
cocoapods(use_bundle_exec: true)
143192

144193
cert(development: false)
145194

@@ -149,22 +198,26 @@ platform :ios do
149198
)
150199

151200
gym(
152-
scheme: main_scheme,
201+
scheme: prod_scheme,
153202
configuration: "Release",
154203
clean: true,
155204
include_bitcode: false,
156-
export_options: { compileBitcode: false},
205+
export_options: {
206+
compileBitcode: false
207+
},
157208
export_method: "app-store"
158209
)
159210

160-
upload_to_fabric
211+
upload_to_app_store(
212+
app_identifier: bundle_name
213+
)
161214

162-
sh("rm ../*.mobileprovision")
215+
refresh_dsyms()
163216
end
164217

218+
desc "Upload a new build to the Fabric"
165219
lane :upload_to_fabric do
166-
167-
# Load in Fabric
220+
# Upload to Fabric
168221
crashlytics(
169222
api_token: "PUT TOKEN HERE",
170223
build_secret: "PUT BUILD SECRET HERE",
@@ -173,6 +226,16 @@ platform :ios do
173226
)
174227
end
175228

229+
230+
desc "Send dSYMS to Fabric"
231+
lane :refresh_dsyms do |options|
232+
bundle_id = bundle_name
233+
234+
download_dsyms(app_identifier: bundle_id, version: 'latest') # Download dSYM files from iTC
235+
upload_symbols_to_crashlytics # Upload them to Crashlytics
236+
clean_build_artifacts # Delete the local dSYM files
237+
end
238+
176239
end
177240

178241

Surf Base Application.xctemplate/fastlane/Pluginfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
# Ensure this file is checked in to source control!
44

55
gem 'fastlane-plugin-git_tags'
6+
gem 'fastlane-plugin-versioning'

0 commit comments

Comments
 (0)