branch_io_cli 0.9.5 → 0.9.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/assets/patches/objc_import_at_end.yml +3 -0
- data/lib/assets/patches/objc_import_include_guard.yml +3 -0
- data/lib/branch_io_cli/command/report_command.rb +16 -9
- data/lib/branch_io_cli/configuration/configuration.rb +21 -2
- data/lib/branch_io_cli/configuration/report_configuration.rb +6 -6
- data/lib/branch_io_cli/configuration/setup_configuration.rb +19 -2
- data/lib/branch_io_cli/core_ext.rb +1 -0
- data/lib/branch_io_cli/core_ext/regexp.rb +14 -0
- data/lib/branch_io_cli/helper/ios_helper.rb +50 -7
- data/lib/branch_io_cli/helper/patch_helper.rb +10 -1
- data/lib/branch_io_cli/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed1b9b67e4bbb2e57d7108b533fd9b77e81d3393eaa229eba07e4964215b6036
|
4
|
+
data.tar.gz: f451658fdddda919cfe70efa48f6a97c0d2458b287ec149b08b392ecb42c8e35
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a536b08af90fa19f98f20a20a145258784dc677c2098209b5c374d700bba5eacd803a98626e7b0633394ef25d13addad8513af449edf1ef690f0c4f1ef92c7a6
|
7
|
+
data.tar.gz: 2880054b91cdb81cf982d5d445d7a23f3d11aac9abaa5a015a7fdf87695e36523b91ac50a080ac9962b7364aec7c73faa7a24d8446522aad29d483969d568660
|
@@ -155,9 +155,12 @@ EOF
|
|
155
155
|
def version_from_branch_framework
|
156
156
|
framework = config.target.frameworks_build_phase.files.find { |f| f.file_ref.path =~ /Branch.framework$/ }
|
157
157
|
return nil unless framework
|
158
|
+
|
158
159
|
if framework.file_ref.isa == "PBXFileReference"
|
160
|
+
project_path = config.relative_path(config.xcodeproj_path)
|
159
161
|
framework_path = framework.file_ref.real_path
|
160
162
|
elsif framework.file_ref.isa == "PBXReferenceProxy" && @xcode_settings
|
163
|
+
project_path = config.relative_path framework.file_ref.remote_ref.proxied_object.project.path
|
161
164
|
framework_path = File.expand_path framework.file_ref.path, @xcode_settings[framework.file_ref.source_tree]
|
162
165
|
end
|
163
166
|
info_plist_path = File.join framework_path.to_s, "Info.plist"
|
@@ -168,7 +171,8 @@ EOF
|
|
168
171
|
raw_info_plist = CFPropertyList::List.new file: info_plist_path
|
169
172
|
info_plist = CFPropertyList.native_types raw_info_plist.value
|
170
173
|
version = info_plist["CFBundleVersion"]
|
171
|
-
|
174
|
+
return nil unless version
|
175
|
+
"#{version} [Branch.framework/Info.plist:#{project_path}]"
|
172
176
|
end
|
173
177
|
|
174
178
|
def version_from_bnc_config_m(project = @config.xcodeproj)
|
@@ -188,7 +192,7 @@ EOF
|
|
188
192
|
matches = /BNC_SDK_VERSION\s+=\s+@"(\d+\.\d+\.\d+)"/m.match bnc_config_m
|
189
193
|
return nil unless matches
|
190
194
|
version = matches[1]
|
191
|
-
"#{version} [BNCConfig.m]"
|
195
|
+
"#{version} [BNCConfig.m:#{config.relative_path project.path}]"
|
192
196
|
end
|
193
197
|
|
194
198
|
def report_configuration
|
@@ -201,8 +205,8 @@ Scheme: #{config.scheme || '(none)'}
|
|
201
205
|
Target: #{config.target || '(none)'}
|
202
206
|
Configuration: #{config.configuration || '(none)'}
|
203
207
|
SDK: #{config.sdk}
|
204
|
-
Podfile: #{config.podfile_path || '(none)'}
|
205
|
-
Cartfile: #{config.cartfile_path || '(none)'}
|
208
|
+
Podfile: #{config.relative_path(config.podfile_path) || '(none)'}
|
209
|
+
Cartfile: #{config.relative_path(config.cartfile_path) || '(none)'}
|
206
210
|
Pod repo update: #{config.pod_repo_update.inspect}
|
207
211
|
Clean: #{config.clean.inspect}
|
208
212
|
EOF
|
@@ -251,9 +255,9 @@ EOF
|
|
251
255
|
header += " Deployment target: #{config.target.deployment_target}\n"
|
252
256
|
header += " Modules #{config.modules_enabled? ? '' : 'not '}enabled\n"
|
253
257
|
header += " Swift #{config.swift_version}\n" if config.swift_version
|
254
|
-
header += " Bridging header: #{config.bridging_header_path}\n" if config.bridging_header_path
|
255
|
-
header += " Info.plist: #{infoplist_path || '(none)'}\n"
|
256
|
-
header += " Entitlements file: #{entitlements_path || '(none)'}\n"
|
258
|
+
header += " Bridging header: #{config.relative_path(config.bridging_header_path)}\n" if config.bridging_header_path
|
259
|
+
header += " Info.plist: #{config.relative_path(infoplist_path) || '(none)'}\n"
|
260
|
+
header += " Entitlements file: #{config.relative_path(entitlements_path) || '(none)'}\n"
|
257
261
|
|
258
262
|
if config.podfile_path
|
259
263
|
begin
|
@@ -325,6 +329,7 @@ EOF
|
|
325
329
|
# String containing information relevant to Branch setup
|
326
330
|
def branch_report
|
327
331
|
infoplist_path = helper.expanded_build_setting config.target, "INFOPLIST_FILE", config.configuration
|
332
|
+
infoplist_path = File.expand_path infoplist_path, File.dirname(config.xcodeproj_path)
|
328
333
|
|
329
334
|
report = "Branch configuration:\n"
|
330
335
|
|
@@ -334,10 +339,12 @@ EOF
|
|
334
339
|
report += " Branch key(s) (Info.plist):\n"
|
335
340
|
if branch_key.kind_of? Hash
|
336
341
|
branch_key.each_key do |key|
|
337
|
-
|
342
|
+
resolved_key = helper.expand_build_settings branch_key[key], config.target, config.configuration
|
343
|
+
report += " #{key.capitalize}: #{resolved_key}\n"
|
338
344
|
end
|
339
345
|
elsif branch_key
|
340
|
-
|
346
|
+
resolved_key = helper.expand_build_settings branch_key, config.target, config.configuration
|
347
|
+
report += " #{resolved_key}\n"
|
341
348
|
else
|
342
349
|
report += " (none found)\n"
|
343
350
|
end
|
@@ -55,6 +55,23 @@ EOF
|
|
55
55
|
Helper::BranchHelper
|
56
56
|
end
|
57
57
|
|
58
|
+
def relative_path(path)
|
59
|
+
return nil if path.nil?
|
60
|
+
|
61
|
+
path = Pathname.new(path) unless path.kind_of? Pathname
|
62
|
+
return path.to_s unless path.absolute?
|
63
|
+
|
64
|
+
unless @root
|
65
|
+
if workspace
|
66
|
+
@root = Pathname.new(workspace_path).dirname
|
67
|
+
else
|
68
|
+
@root = Pathname.new(xcodeproj_path).dirname
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
path.relative_path_from(@root).to_s
|
73
|
+
end
|
74
|
+
|
58
75
|
# 1. Look for options.xcodeproj.
|
59
76
|
# 2. If not specified, look for projects under . (excluding anything in Pods or Carthage folder).
|
60
77
|
# 3. If none or more than one found, prompt the user.
|
@@ -81,7 +98,7 @@ EOF
|
|
81
98
|
# TODO: Allow the user to choose if xcodeproj_paths.count > 0
|
82
99
|
begin
|
83
100
|
@xcodeproj = Xcodeproj::Project.open path
|
84
|
-
@xcodeproj_path = path
|
101
|
+
@xcodeproj_path = File.expand_path path
|
85
102
|
return
|
86
103
|
rescue StandardError => e
|
87
104
|
say e.message
|
@@ -140,6 +157,7 @@ EOF
|
|
140
157
|
def open_podfile(path = @podfile_path)
|
141
158
|
@podfile = Pod::Podfile.from_file path
|
142
159
|
@podfile_path = path
|
160
|
+
@sdk_integration_mode = :cocoapods
|
143
161
|
true
|
144
162
|
rescue RuntimeError => e
|
145
163
|
say e.message
|
@@ -152,13 +170,14 @@ EOF
|
|
152
170
|
|
153
171
|
if valid
|
154
172
|
valid = File.exist? buildfile_path
|
155
|
-
say "#{buildfile_path} not found." unless valid
|
173
|
+
say "#{buildfile_path} not found." and return false unless valid
|
156
174
|
end
|
157
175
|
|
158
176
|
if filename == "Podfile" && open_podfile(buildfile_path)
|
159
177
|
true
|
160
178
|
elsif filename == "Cartfile"
|
161
179
|
@cartfile_path = buildfile_path
|
180
|
+
@sdk_integration_mode = :carthage
|
162
181
|
true
|
163
182
|
else
|
164
183
|
false
|
@@ -42,8 +42,8 @@ module BranchIOCLI
|
|
42
42
|
<%= color('Target:', BOLD) %> #{target || '(none)'}
|
43
43
|
<%= color('Configuration:', BOLD) %> #{configuration}
|
44
44
|
<%= color('SDK:', BOLD) %> #{sdk}
|
45
|
-
<%= color('Podfile:', BOLD) %> #{podfile_path || '(none)'}
|
46
|
-
<%= color('Cartfile:', BOLD) %> #{cartfile_path || '(none)'}
|
45
|
+
<%= color('Podfile:', BOLD) %> #{relative_path(podfile_path) || '(none)'}
|
46
|
+
<%= color('Cartfile:', BOLD) %> #{relative_path(cartfile_path) || '(none)'}
|
47
47
|
<%= color('Pod repo update:', BOLD) %> #{pod_repo_update.inspect}
|
48
48
|
<%= color('Clean:', BOLD) %> #{clean.inspect}
|
49
49
|
<%= color('Report path:', BOLD) %> #{report_path}
|
@@ -57,12 +57,12 @@ EOF
|
|
57
57
|
if options.workspace
|
58
58
|
path = options.workspace
|
59
59
|
@workspace = Xcodeproj::Workspace.new_from_xcworkspace options.workspace
|
60
|
-
@workspace_path = options.workspace
|
60
|
+
@workspace_path = File.expand_path options.workspace
|
61
61
|
end
|
62
62
|
if options.xcodeproj
|
63
63
|
path = options.xcodeproj
|
64
64
|
@xcodeproj = Xcodeproj::Project.open options.xcodeproj
|
65
|
-
@xcodeproj_path = options.xcodeproj
|
65
|
+
@xcodeproj_path = File.expand_path options.xcodeproj
|
66
66
|
else
|
67
67
|
# Pass --workspace and --xcodeproj to override this inference.
|
68
68
|
if workspace && workspace.file_references.count > 0 && workspace.file_references.first.path =~ /\.xcodeproj$/
|
@@ -107,7 +107,7 @@ EOF
|
|
107
107
|
begin
|
108
108
|
if path =~ /\.xcworkspace$/
|
109
109
|
@workspace = Xcodeproj::Workspace.new_from_xcworkspace path
|
110
|
-
@workspace_path = path
|
110
|
+
@workspace_path = File.expand_path path
|
111
111
|
|
112
112
|
# Pass --workspace and --xcodeproj to override this inference.
|
113
113
|
if workspace.file_references.count > 0 && workspace.file_references.first.path =~ /\.xcodeproj$/
|
@@ -118,7 +118,7 @@ EOF
|
|
118
118
|
return
|
119
119
|
elsif path =~ /\.xcodeproj$/
|
120
120
|
@xcodeproj = Xcodeproj::Project.open path
|
121
|
-
@xcodeproj_path = path
|
121
|
+
@xcodeproj_path = File.expand_path path
|
122
122
|
return
|
123
123
|
else
|
124
124
|
say "Path must end with .xcworkspace or .xcodeproj"
|
@@ -4,6 +4,7 @@ module BranchIOCLI
|
|
4
4
|
APP_LINK_REGEXP = /\.app\.link$|\.test-app\.link$/
|
5
5
|
SDK_OPTIONS =
|
6
6
|
{
|
7
|
+
"Specify the location of a Podfile or Cartfile" => :specify,
|
7
8
|
"Set this project up to use CocoaPods and add the Branch SDK." => :cocoapods,
|
8
9
|
"Set this project up to use Carthage and add the Branch SDK." => :carthage,
|
9
10
|
"Add Branch.framework directly to the project's dependencies." => :direct,
|
@@ -62,8 +63,8 @@ module BranchIOCLI
|
|
62
63
|
<%= color('Test key:', BOLD) %> #{keys[:test] || '(none)'}
|
63
64
|
<%= color('Domains:', BOLD) %> #{all_domains}
|
64
65
|
<%= color('URI scheme:', BOLD) %> #{uri_scheme || '(none)'}
|
65
|
-
<%= color('Podfile:', BOLD) %> #{podfile_path || '(none)'}
|
66
|
-
<%= color('Cartfile:', BOLD) %> #{cartfile_path || '(none)'}
|
66
|
+
<%= color('Podfile:', BOLD) %> #{relative_path(podfile_path) || '(none)'}
|
67
|
+
<%= color('Cartfile:', BOLD) %> #{relative_path(cartfile_path) || '(none)'}
|
67
68
|
<%= color('Carthage command:', BOLD) %> #{carthage_command || '(none)'}
|
68
69
|
<%= color('Pod repo update:', BOLD) %> #{pod_repo_update.inspect}
|
69
70
|
<%= color('Validate:', BOLD) %> #{validate.inspect}
|
@@ -183,6 +184,20 @@ module BranchIOCLI
|
|
183
184
|
scheme.sub %r{://$}, ""
|
184
185
|
end
|
185
186
|
|
187
|
+
def prompt_for_podfile_or_cartfile
|
188
|
+
loop do
|
189
|
+
path = ask("Please enter the location of your Podfile or Cartfile: ").trim
|
190
|
+
case path
|
191
|
+
when %r{/?Podfile$}
|
192
|
+
return if validate_buildfile_at_path path, "Podfile"
|
193
|
+
when %r{/?Cartfile$}
|
194
|
+
return if validate_buildfile_at_path path, "Cartfile"
|
195
|
+
else
|
196
|
+
say "Path must end in Podfile or Cartfile."
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
186
201
|
def validate_sdk_addition(options)
|
187
202
|
return if !options.add_sdk || sdk_integration_mode
|
188
203
|
|
@@ -202,6 +217,8 @@ module BranchIOCLI
|
|
202
217
|
@sdk_integration_mode = SDK_OPTIONS[selected]
|
203
218
|
|
204
219
|
case sdk_integration_mode
|
220
|
+
when :specify
|
221
|
+
prompt_for_podfile_or_cartfile
|
205
222
|
when :cocoapods
|
206
223
|
@podfile_path = File.expand_path "../Podfile", xcodeproj_path
|
207
224
|
when :carthage
|
@@ -372,7 +372,14 @@ module BranchIOCLI
|
|
372
372
|
end
|
373
373
|
|
374
374
|
def expanded_build_setting(target, setting_name, configuration)
|
375
|
-
|
375
|
+
# second arg true means if there is an xcconfig, also consult that
|
376
|
+
begin
|
377
|
+
setting_value = target.resolved_build_setting(setting_name, true)[configuration]
|
378
|
+
rescue Errno::ENOENT
|
379
|
+
# If not found, look up without it
|
380
|
+
setting_value = target.resolved_build_setting(setting_name, false)[configuration]
|
381
|
+
end
|
382
|
+
|
376
383
|
return if setting_value.nil?
|
377
384
|
|
378
385
|
expand_build_settings setting_value, target, configuration
|
@@ -380,14 +387,50 @@ module BranchIOCLI
|
|
380
387
|
|
381
388
|
def expand_build_settings(string, target, configuration)
|
382
389
|
search_position = 0
|
383
|
-
|
384
|
-
|
385
|
-
|
390
|
+
# It's safest to make a copy of this string, though we probably get a
|
391
|
+
# copy from PBXNativeTarget#resolve_build_setting anyway. Copying here
|
392
|
+
# avoids a copy on every match.
|
393
|
+
string = string.clone
|
394
|
+
|
395
|
+
# HACK: When matching against an xcconfig, as here, sometimes the macro is just returned
|
396
|
+
# without delimiters, e.g. TARGET_NAME or BUILT_PRODUCTS_DIR/Branch.framework. We allow
|
397
|
+
# these two patterns for now.
|
398
|
+
while (matches = %r{\$\(([^(){}]*)\)|\$\{([^(){}]*)\}|^([A-Z_]+)(/.*)?$}.match(string, search_position))
|
399
|
+
original_macro = matches[1] || matches[2] || matches[3]
|
400
|
+
delimiter_length = matches[3] ? 0 : 3 # $() or ${}
|
401
|
+
delimiter_offset = matches[3] ? 0 : 2 # $( or ${
|
402
|
+
search_position = string.index(original_macro) - delimiter_offset
|
403
|
+
|
404
|
+
modifier_regexp = /^(.+):(.+)$/
|
405
|
+
if (matches = modifier_regexp.match original_macro)
|
406
|
+
macro_name = matches[1]
|
407
|
+
modifier = matches[2]
|
408
|
+
else
|
409
|
+
macro_name = original_macro
|
410
|
+
end
|
386
411
|
|
387
|
-
|
388
|
-
|
412
|
+
case macro_name
|
413
|
+
when "SRCROOT"
|
414
|
+
expanded_macro = "."
|
415
|
+
when "TARGET_NAME"
|
416
|
+
# Clone in case of modifier processing
|
417
|
+
expanded_macro = target.name.clone
|
418
|
+
else
|
419
|
+
expanded_macro = expanded_build_setting(target, macro_name, configuration)
|
420
|
+
end
|
421
|
+
|
422
|
+
search_position += original_macro.length + delimiter_length and next if expanded_macro.nil?
|
423
|
+
|
424
|
+
if modifier == "rfc1034identifier"
|
425
|
+
# From the Apple dev portal when creating a new app ID:
|
426
|
+
# You cannot use special characters such as @, &, *, ', "
|
427
|
+
# From trial and error with Xcode, it appears that only letters, digits and hyphens are allowed.
|
428
|
+
# Everything else becomes a hyphen, including underscores.
|
429
|
+
special_chars = /[^A-Za-z0-9-]/
|
430
|
+
expanded_macro.gsub!(special_chars, '-')
|
431
|
+
end
|
389
432
|
|
390
|
-
string.gsub!(/\$\(#{
|
433
|
+
string.gsub!(/\$\(#{original_macro}\)|\$\{#{original_macro}\}|^#{original_macro}/, expanded_macro)
|
391
434
|
search_position += expanded_macro.length
|
392
435
|
end
|
393
436
|
string
|
@@ -44,7 +44,16 @@ module BranchIOCLI
|
|
44
44
|
|
45
45
|
say "Patching #{config.bridging_header_path}"
|
46
46
|
|
47
|
-
|
47
|
+
if /^\s*(#import|#include|@import)/.match_file config.bridging_header_path
|
48
|
+
# Add among other imports
|
49
|
+
load_patch(:objc_import).apply config.bridging_header_path
|
50
|
+
elsif /\n\s*#ifndef\s+(\w+).*\n\s*#define\s+\1.*?\n/m.match_file config.bridging_header_path
|
51
|
+
# Has an include guard. Add inside.
|
52
|
+
load_patch(:objc_import_include_guard).apply config.bridging_header_path
|
53
|
+
else
|
54
|
+
# No imports, no include guard. Add at the end.
|
55
|
+
load_patch(:objc_import_at_end).apply config.bridging_header_path
|
56
|
+
end
|
48
57
|
helper.add_change config.bridging_header_path
|
49
58
|
end
|
50
59
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: branch_io_cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Branch
|
@@ -272,6 +272,8 @@ files:
|
|
272
272
|
- lib/assets/patches/did_finish_launching_objc.yml
|
273
273
|
- lib/assets/patches/did_finish_launching_swift.yml
|
274
274
|
- lib/assets/patches/objc_import.yml
|
275
|
+
- lib/assets/patches/objc_import_at_end.yml
|
276
|
+
- lib/assets/patches/objc_import_include_guard.yml
|
275
277
|
- lib/assets/patches/open_url_new_objc.yml
|
276
278
|
- lib/assets/patches/open_url_new_swift.yml
|
277
279
|
- lib/assets/patches/open_url_objc.yml
|
@@ -293,6 +295,7 @@ files:
|
|
293
295
|
- lib/branch_io_cli/configuration/validate_configuration.rb
|
294
296
|
- lib/branch_io_cli/core_ext.rb
|
295
297
|
- lib/branch_io_cli/core_ext/io.rb
|
298
|
+
- lib/branch_io_cli/core_ext/regexp.rb
|
296
299
|
- lib/branch_io_cli/helper.rb
|
297
300
|
- lib/branch_io_cli/helper/android_helper.rb
|
298
301
|
- lib/branch_io_cli/helper/branch_helper.rb
|
@@ -320,7 +323,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
320
323
|
version: '0'
|
321
324
|
requirements: []
|
322
325
|
rubyforge_project:
|
323
|
-
rubygems_version: 2.7.
|
326
|
+
rubygems_version: 2.7.2
|
324
327
|
signing_key:
|
325
328
|
specification_version: 4
|
326
329
|
summary: Branch.io command-line interface for mobile app integration
|