branch_io_cli 0.9.7 → 0.9.8
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/MessagesDidBecomeActive.m +16 -0
- data/lib/assets/patches/MessagesDidBecomeActive.swift +16 -0
- data/lib/assets/patches/messages_did_become_active_new_objc.yml +3 -0
- data/lib/assets/patches/messages_did_become_active_new_swift.yml +3 -0
- data/lib/assets/patches/messages_did_become_active_objc.yml +3 -0
- data/lib/assets/patches/messages_did_become_active_swift.yml +3 -0
- data/lib/branch_io_cli/command/command.rb +7 -1
- data/lib/branch_io_cli/command/report_command.rb +15 -329
- data/lib/branch_io_cli/command/setup_command.rb +0 -1
- data/lib/branch_io_cli/command/validate_command.rb +0 -5
- data/lib/branch_io_cli/configuration.rb +1 -0
- data/lib/branch_io_cli/configuration/configuration.rb +48 -2
- data/lib/branch_io_cli/configuration/report_configuration.rb +155 -2
- data/lib/branch_io_cli/configuration/xcode_settings.rb +66 -0
- data/lib/branch_io_cli/helper/branch_helper.rb +0 -1
- data/lib/branch_io_cli/helper/ios_helper.rb +5 -3
- data/lib/branch_io_cli/helper/methods.rb +9 -2
- data/lib/branch_io_cli/helper/patch_helper.rb +34 -0
- data/lib/branch_io_cli/helper/report_helper.rb +164 -0
- data/lib/branch_io_cli/version.rb +1 -1
- metadata +9 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '091b67267f6d542453cd8903adf229f0caeec5b763b33ab2474c308a2bfcb6cb'
|
4
|
+
data.tar.gz: 421065a8099c0d6e1087c641dea2d303b21aab989e53f9ae3825ab58ccaeb8f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24ff573c11e248b4d9501e1e8d464d37980b3dc998e2150796979714be12c9d1a415946387a4cc8c1df86f532b8297b1e11a908c464cc712c5d8b6016d680890
|
7
|
+
data.tar.gz: 991c8328c42eaf101c7fa780b4b7e18150fd25db9237e0a97b0218f0ba7ca4a5a73af89cc4b3672765940753d832cb0c0f412234c9aa185a9c0b5fc514ba41ba
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<% if is_new_method %>
|
2
|
+
|
3
|
+
-(void)didBecomeActiveWithConversation:(MSConversation *)conversation {
|
4
|
+
<% end %>
|
5
|
+
<% if use_conditional_test_key? %>
|
6
|
+
#ifdef DEBUG
|
7
|
+
[Branch setUseTestBranchKey:YES];
|
8
|
+
#endif // DEBUG
|
9
|
+
<% end %>
|
10
|
+
[[Branch getInstance] initSessionWithLaunchOptions:@{}
|
11
|
+
andRegisterDeepLinkHandlerUsingBranchUniversalObject:^(BranchUniversalObject *universalObject, BranchLinkProperties *linkProperties, NSError *error){
|
12
|
+
// TODO: Route Branch links
|
13
|
+
}];
|
14
|
+
<% if is_new_method %>
|
15
|
+
}
|
16
|
+
<% end %>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<% if is_new_method %>
|
2
|
+
override func didBecomeActive(with conversation: MSConversation) {
|
3
|
+
<% end %>
|
4
|
+
<% if use_conditional_test_key? %>
|
5
|
+
#if DEBUG
|
6
|
+
Branch.setUseTestBranchKey(true)
|
7
|
+
#endif
|
8
|
+
<% end %>
|
9
|
+
Branch.getInstance().initSession(launchOptions: [:]) {
|
10
|
+
universalObject, linkProperties, error in
|
11
|
+
|
12
|
+
// TODO: Route Branch links
|
13
|
+
}
|
14
|
+
<% if is_new_method %>
|
15
|
+
}
|
16
|
+
<% end %>
|
@@ -1,11 +1,17 @@
|
|
1
1
|
module BranchIOCLI
|
2
2
|
module Command
|
3
3
|
class Command
|
4
|
-
attr_reader :options
|
4
|
+
attr_reader :options # command-specific options from CLI
|
5
5
|
attr_reader :config # command-specific configuration object
|
6
6
|
|
7
7
|
def initialize(options)
|
8
8
|
@options = options
|
9
|
+
matches = /BranchIOCLI::Command::(\w+)Command/.match self.class.name
|
10
|
+
root = matches[1]
|
11
|
+
|
12
|
+
@config = Object.const_get("BranchIOCLI")
|
13
|
+
.const_get("Configuration")
|
14
|
+
.const_get("#{root}Configuration").new options
|
9
15
|
end
|
10
16
|
|
11
17
|
def run!
|
@@ -1,31 +1,22 @@
|
|
1
|
-
require "
|
2
|
-
require "branch_io_cli/helper/methods"
|
3
|
-
require "open3"
|
4
|
-
require "plist"
|
5
|
-
require "xcodeproj"
|
1
|
+
require "shellwords"
|
6
2
|
|
7
3
|
module BranchIOCLI
|
8
4
|
module Command
|
9
5
|
class ReportCommand < Command
|
10
|
-
def initialize(options)
|
11
|
-
super
|
12
|
-
@config = Configuration::ReportConfiguration.new options
|
13
|
-
end
|
14
|
-
|
15
6
|
def run!
|
16
7
|
say "\n"
|
17
8
|
|
18
|
-
unless
|
9
|
+
unless xcode_settings.valid?
|
19
10
|
say "Failed to load settings from Xcode. Some information may be missing.\n"
|
20
11
|
end
|
21
12
|
|
22
13
|
if config.header_only
|
23
|
-
say report_header
|
14
|
+
say report_helper.report_header
|
24
15
|
exit 0
|
25
16
|
end
|
26
17
|
|
27
18
|
# Only if a Podfile is detected/supplied at the command line.
|
28
|
-
if pod_install_required?
|
19
|
+
if config.pod_install_required?
|
29
20
|
say "pod install required in order to build."
|
30
21
|
install = ask %{Run "pod install" now (Y/n)? }
|
31
22
|
if install.downcase =~ /^n/
|
@@ -52,33 +43,28 @@ EOF
|
|
52
43
|
|
53
44
|
File.open config.report_path, "w" do |report|
|
54
45
|
report.write "Branch.io Xcode build report v #{VERSION} #{DateTime.now}\n\n"
|
55
|
-
report.write "#{report_configuration}\n"
|
56
|
-
report.write "#{report_header}\n"
|
46
|
+
report.write "#{config.report_configuration}\n"
|
47
|
+
report.write "#{report_helper.report_header}\n"
|
57
48
|
|
58
49
|
# run xcodebuild -list
|
59
|
-
report.log_command "#{base_xcodebuild_cmd} -list"
|
50
|
+
report.log_command "#{report_helper.base_xcodebuild_cmd} -list"
|
60
51
|
|
61
52
|
# If using a workspace, -list all the projects as well
|
62
53
|
if config.workspace_path
|
63
54
|
config.workspace.file_references.map(&:path).each do |project_path|
|
64
55
|
path = File.join File.dirname(config.workspace_path), project_path
|
65
|
-
report.log_command "xcodebuild -list -project #{path}"
|
56
|
+
report.log_command "xcodebuild -list -project #{Shellwords.escape path}"
|
66
57
|
end
|
67
58
|
end
|
68
59
|
|
69
|
-
base_cmd = base_xcodebuild_cmd
|
60
|
+
base_cmd = report_helper.base_xcodebuild_cmd
|
70
61
|
# Add more options for the rest of the commands
|
71
|
-
base_cmd
|
72
|
-
base_cmd
|
62
|
+
base_cmd += " -scheme #{Shellwords.escape config.scheme}"
|
63
|
+
base_cmd += " -configuration #{Shellwords.escape config.configuration}"
|
64
|
+
base_cmd += " -sdk #{Shellwords.escape config.sdk}"
|
73
65
|
|
74
66
|
# xcodebuild -showBuildSettings
|
75
|
-
|
76
|
-
report.write @xcodebuild_showbuildsettings_output
|
77
|
-
if @xcodebuild_showbuildsettings_status.success?
|
78
|
-
report.write "Success.\n\n"
|
79
|
-
else
|
80
|
-
report.write "#{@xcodebuild_showbuildsettings_status}.\n\n"
|
81
|
-
end
|
67
|
+
xcode_settings.log_xcodebuild_showbuildsettings report
|
82
68
|
|
83
69
|
if config.clean
|
84
70
|
say "Cleaning"
|
@@ -98,308 +84,8 @@ EOF
|
|
98
84
|
Helper::ReportHelper
|
99
85
|
end
|
100
86
|
|
101
|
-
def
|
102
|
-
|
103
|
-
if config.workspace_path
|
104
|
-
cmd = "#{cmd} -workspace #{config.workspace_path}"
|
105
|
-
else
|
106
|
-
cmd = "#{cmd} -project #{config.xcodeproj_path}"
|
107
|
-
end
|
108
|
-
cmd
|
109
|
-
end
|
110
|
-
|
111
|
-
def branch_version
|
112
|
-
version_from_podfile_lock ||
|
113
|
-
version_from_cartfile_resolved ||
|
114
|
-
version_from_branch_framework ||
|
115
|
-
version_from_bnc_config_m
|
116
|
-
end
|
117
|
-
|
118
|
-
def requirement_from_podfile
|
119
|
-
return nil unless config.podfile_path
|
120
|
-
podfile = File.read config.podfile_path
|
121
|
-
matches = /\n?\s*pod\s+("Branch"|'Branch').*?\n/m.match podfile
|
122
|
-
matches ? matches[0].strip : nil
|
123
|
-
end
|
124
|
-
|
125
|
-
def requirement_from_cartfile
|
126
|
-
return nil unless config.cartfile_path
|
127
|
-
cartfile = File.read config.cartfile_path
|
128
|
-
matches = %r{^git(hub\s+"|\s+"https://github.com/)BranchMetrics/(ios-branch-deep-linking|iOS-Deferred-Deep-Linking-SDK.*?).*?\n}m.match cartfile
|
129
|
-
matches ? matches[0].strip : nil
|
130
|
-
end
|
131
|
-
|
132
|
-
def version_from_podfile_lock
|
133
|
-
return nil unless config.podfile_path && File.exist?("#{config.podfile_path}.lock")
|
134
|
-
podfile_lock = Pod::Lockfile.from_file Pathname.new "#{config.podfile_path}.lock"
|
135
|
-
version = podfile_lock.version("Branch") || podfile_lock.version("Branch-SDK")
|
136
|
-
|
137
|
-
version ? "#{version} [Podfile.lock]" : nil
|
138
|
-
end
|
139
|
-
|
140
|
-
def version_from_cartfile_resolved
|
141
|
-
return nil unless config.cartfile_path && File.exist?("#{config.cartfile_path}.resolved")
|
142
|
-
cartfile_resolved = File.read "#{config.cartfile_path}.resolved"
|
143
|
-
|
144
|
-
# Matches:
|
145
|
-
# git "https://github.com/BranchMetrics/ios-branch-deep-linking"
|
146
|
-
# git "https://github.com/BranchMetrics/ios-branch-deep-linking/"
|
147
|
-
# git "https://github.com/BranchMetrics/iOS-Deferred-Deep-Linking-SDK"
|
148
|
-
# git "https://github.com/BranchMetrics/iOS-Deferred-Deep-Linking-SDK/"
|
149
|
-
# github "BranchMetrics/ios-branch-deep-linking"
|
150
|
-
# github "BranchMetrics/ios-branch-deep-linking/"
|
151
|
-
# github "BranchMetrics/iOS-Deferred-Deep-Linking-SDK"
|
152
|
-
# github "BranchMetrics/iOS-Deferred-Deep-Linking-SDK/"
|
153
|
-
matches = %r{(ios-branch-deep-linking|iOS-Deferred-Deep-Linking-SDK)/?" "(\d+\.\d+\.\d+)"}m.match cartfile_resolved
|
154
|
-
return nil unless matches
|
155
|
-
version = matches[2]
|
156
|
-
"#{version} [Cartfile.resolved]"
|
157
|
-
end
|
158
|
-
|
159
|
-
def version_from_branch_framework
|
160
|
-
framework = config.target.frameworks_build_phase.files.find { |f| f.file_ref.path =~ /Branch.framework$/ }
|
161
|
-
return nil unless framework
|
162
|
-
|
163
|
-
if framework.file_ref.isa == "PBXFileReference"
|
164
|
-
project_path = config.relative_path(config.xcodeproj_path)
|
165
|
-
framework_path = framework.file_ref.real_path
|
166
|
-
elsif framework.file_ref.isa == "PBXReferenceProxy" && @xcode_settings
|
167
|
-
project_path = config.relative_path framework.file_ref.remote_ref.proxied_object.project.path
|
168
|
-
framework_path = File.expand_path framework.file_ref.path, @xcode_settings[framework.file_ref.source_tree]
|
169
|
-
end
|
170
|
-
info_plist_path = File.join framework_path.to_s, "Info.plist"
|
171
|
-
return nil unless File.exist? info_plist_path
|
172
|
-
|
173
|
-
require "cfpropertylist"
|
174
|
-
|
175
|
-
raw_info_plist = CFPropertyList::List.new file: info_plist_path
|
176
|
-
info_plist = CFPropertyList.native_types raw_info_plist.value
|
177
|
-
version = info_plist["CFBundleVersion"]
|
178
|
-
return nil unless version
|
179
|
-
"#{version} [Branch.framework/Info.plist:#{project_path}]"
|
180
|
-
end
|
181
|
-
|
182
|
-
def version_from_bnc_config_m(project = @config.xcodeproj)
|
183
|
-
# Look for BNCConfig.m in embedded source
|
184
|
-
bnc_config_m_ref = project.files.find { |f| f.path =~ /BNCConfig\.m$/ }
|
185
|
-
unless bnc_config_m_ref
|
186
|
-
subprojects = project.files.select { |f| f.path =~ /\.xcodeproj$/ }
|
187
|
-
subprojects.each do |subproject|
|
188
|
-
p = Xcodeproj::Project.open subproject.real_path
|
189
|
-
version = version_from_bnc_config_m p
|
190
|
-
return version if version
|
191
|
-
end
|
192
|
-
end
|
193
|
-
|
194
|
-
return nil unless bnc_config_m_ref
|
195
|
-
bnc_config_m = File.read bnc_config_m_ref.real_path
|
196
|
-
matches = /BNC_SDK_VERSION\s+=\s+@"(\d+\.\d+\.\d+)"/m.match bnc_config_m
|
197
|
-
return nil unless matches
|
198
|
-
version = matches[1]
|
199
|
-
"#{version} [BNCConfig.m:#{config.relative_path project.path}]"
|
200
|
-
end
|
201
|
-
|
202
|
-
def report_configuration
|
203
|
-
<<EOF
|
204
|
-
Configuration:
|
205
|
-
|
206
|
-
Xcode workspace: #{config.workspace_path || '(none)'}
|
207
|
-
Xcode project: #{config.xcodeproj_path || '(none)'}
|
208
|
-
Scheme: #{config.scheme || '(none)'}
|
209
|
-
Target: #{config.target || '(none)'}
|
210
|
-
Configuration: #{config.configuration || '(none)'}
|
211
|
-
SDK: #{config.sdk}
|
212
|
-
Podfile: #{config.relative_path(config.podfile_path) || '(none)'}
|
213
|
-
Cartfile: #{config.relative_path(config.cartfile_path) || '(none)'}
|
214
|
-
Pod repo update: #{config.pod_repo_update.inspect}
|
215
|
-
Clean: #{config.clean.inspect}
|
216
|
-
EOF
|
217
|
-
end
|
218
|
-
|
219
|
-
def pod_install_required?
|
220
|
-
# If this is set, its existence has been verified.
|
221
|
-
return false unless config.podfile_path
|
222
|
-
|
223
|
-
lockfile_path = "#{config.podfile_path}.lock"
|
224
|
-
manifest_path = File.expand_path "../Pods/Manifest.lock", config.podfile_path
|
225
|
-
|
226
|
-
return true unless File.exist?(lockfile_path) && File.exist?(manifest_path)
|
227
|
-
|
228
|
-
lockfile = Pod::Lockfile.from_file Pathname.new lockfile_path
|
229
|
-
manifest = Pod::Lockfile.from_file Pathname.new manifest_path
|
230
|
-
|
231
|
-
# diff the contents of Podfile.lock and Pods/Manifest.lock
|
232
|
-
# This is just what is done in the "[CP] Check Pods Manifest.lock" script build phase
|
233
|
-
# in a project using CocoaPods.
|
234
|
-
return true unless lockfile == manifest
|
235
|
-
|
236
|
-
# compare checksum of Podfile with checksum in Podfile.lock
|
237
|
-
# This is a good sanity check, but perhaps unnecessary. It means pod install
|
238
|
-
# has not been run since the Podfile was modified, which is probably an oversight.
|
239
|
-
return true unless lockfile.to_hash["PODFILE CHECKSUM"] == config.podfile.checksum
|
240
|
-
|
241
|
-
false
|
242
|
-
end
|
243
|
-
|
244
|
-
# rubocop: disable Metrics/PerceivedComplexity
|
245
|
-
def report_header
|
246
|
-
header = "cocoapods-core: #{Pod::CORE_VERSION}\n"
|
247
|
-
|
248
|
-
header += `xcodebuild -version`
|
249
|
-
header += "SDK: #{@xcode_settings['SDK_NAME']}\n" if @xcode_settings
|
250
|
-
|
251
|
-
bundle_identifier = helper.expanded_build_setting config.target, "PRODUCT_BUNDLE_IDENTIFIER", config.configuration
|
252
|
-
dev_team = helper.expanded_build_setting config.target, "DEVELOPMENT_TEAM", config.configuration
|
253
|
-
infoplist_path = helper.expanded_build_setting config.target, "INFOPLIST_FILE", config.configuration
|
254
|
-
entitlements_path = helper.expanded_build_setting config.target, "CODE_SIGN_ENTITLEMENTS", config.configuration
|
255
|
-
|
256
|
-
header += "\nTarget #{config.target.name}:\n"
|
257
|
-
header += " Bundle identifier: #{bundle_identifier || '(none)'}\n"
|
258
|
-
header += " Development team: #{dev_team || '(none)'}\n"
|
259
|
-
header += " Deployment target: #{config.target.deployment_target}\n"
|
260
|
-
header += " Modules #{config.modules_enabled? ? '' : 'not '}enabled\n"
|
261
|
-
header += " Swift #{config.swift_version}\n" if config.swift_version
|
262
|
-
header += " Bridging header: #{config.relative_path(config.bridging_header_path)}\n" if config.bridging_header_path
|
263
|
-
header += " Info.plist: #{config.relative_path(infoplist_path) || '(none)'}\n"
|
264
|
-
header += " Entitlements file: #{config.relative_path(entitlements_path) || '(none)'}\n"
|
265
|
-
|
266
|
-
if config.podfile_path
|
267
|
-
begin
|
268
|
-
cocoapods_version = `pod --version`.chomp
|
269
|
-
rescue Errno::ENOENT
|
270
|
-
header += "\n(pod command not found)\n"
|
271
|
-
end
|
272
|
-
|
273
|
-
if File.exist?("#{config.podfile_path}.lock")
|
274
|
-
podfile_lock = Pod::Lockfile.from_file Pathname.new "#{config.podfile_path}.lock"
|
275
|
-
end
|
276
|
-
|
277
|
-
if cocoapods_version || podfile_lock
|
278
|
-
header += "\nUsing CocoaPods v. "
|
279
|
-
if cocoapods_version
|
280
|
-
header += "#{cocoapods_version} (CLI) "
|
281
|
-
end
|
282
|
-
if podfile_lock
|
283
|
-
header += "#{podfile_lock.cocoapods_version} (Podfile.lock)"
|
284
|
-
end
|
285
|
-
header += "\n"
|
286
|
-
end
|
287
|
-
|
288
|
-
target_definition = config.podfile.target_definitions[config.target.name]
|
289
|
-
if target_definition
|
290
|
-
branch_deps = target_definition.dependencies.select { |p| p.name =~ %r{^(Branch|Branch-SDK)(/.*)?$} }
|
291
|
-
header += "Podfile target #{target_definition.name}:"
|
292
|
-
header += "\n use_frameworks!" if target_definition.uses_frameworks?
|
293
|
-
header += "\n platform: #{target_definition.platform}"
|
294
|
-
header += "\n build configurations: #{target_definition.build_configurations}"
|
295
|
-
header += "\n inheritance: #{target_definition.inheritance}"
|
296
|
-
branch_deps.each do |dep|
|
297
|
-
header += "\n pod '#{dep.name}', '#{dep.requirement}'"
|
298
|
-
header += ", #{dep.external_source}" if dep.external_source
|
299
|
-
header += "\n"
|
300
|
-
end
|
301
|
-
else
|
302
|
-
header += "Target #{config.target.name.inspect} not found in Podfile.\n"
|
303
|
-
end
|
304
|
-
|
305
|
-
header += "\npod install #{pod_install_required? ? '' : 'not '}required.\n"
|
306
|
-
end
|
307
|
-
|
308
|
-
if config.cartfile_path
|
309
|
-
begin
|
310
|
-
carthage_version = `carthage version`.chomp
|
311
|
-
header += "\nUsing Carthage v. #{carthage_version}\n"
|
312
|
-
rescue Errno::ENOENT
|
313
|
-
header += "\n(carthage command not found)\n"
|
314
|
-
end
|
315
|
-
end
|
316
|
-
|
317
|
-
cartfile_requirement = requirement_from_cartfile
|
318
|
-
header += "\nFrom Cartfile:\n#{cartfile_requirement}\n" if cartfile_requirement
|
319
|
-
|
320
|
-
version = branch_version
|
321
|
-
if version
|
322
|
-
header += "\nBranch SDK v. #{version}\n"
|
323
|
-
else
|
324
|
-
header += "\nBranch SDK not found.\n"
|
325
|
-
end
|
326
|
-
|
327
|
-
header += "\n#{branch_report}"
|
328
|
-
|
329
|
-
header
|
330
|
-
end
|
331
|
-
# rubocop: enable Metrics/PerceivedComplexity
|
332
|
-
|
333
|
-
# String containing information relevant to Branch setup
|
334
|
-
def branch_report
|
335
|
-
infoplist_path = helper.expanded_build_setting config.target, "INFOPLIST_FILE", config.configuration
|
336
|
-
infoplist_path = File.expand_path infoplist_path, File.dirname(config.xcodeproj_path)
|
337
|
-
|
338
|
-
report = "Branch configuration:\n"
|
339
|
-
|
340
|
-
begin
|
341
|
-
info_plist = File.open(infoplist_path) { |f| Plist.parse_xml f }
|
342
|
-
branch_key = info_plist["branch_key"]
|
343
|
-
report += " Branch key(s) (Info.plist):\n"
|
344
|
-
if branch_key.kind_of? Hash
|
345
|
-
branch_key.each_key do |key|
|
346
|
-
resolved_key = helper.expand_build_settings branch_key[key], config.target, config.configuration
|
347
|
-
report += " #{key.capitalize}: #{resolved_key}\n"
|
348
|
-
end
|
349
|
-
elsif branch_key
|
350
|
-
resolved_key = helper.expand_build_settings branch_key, config.target, config.configuration
|
351
|
-
report += " #{resolved_key}\n"
|
352
|
-
else
|
353
|
-
report += " (none found)\n"
|
354
|
-
end
|
355
|
-
|
356
|
-
branch_universal_link_domains = info_plist["branch_universal_link_domains"]
|
357
|
-
if branch_universal_link_domains
|
358
|
-
if branch_universal_link_domains.kind_of? Array
|
359
|
-
report += " branch_universal_link_domains (Info.plist):\n"
|
360
|
-
branch_universal_link_domains.each do |domain|
|
361
|
-
report += " #{domain}\n"
|
362
|
-
end
|
363
|
-
else
|
364
|
-
report += " branch_universal_link_domains (Info.plist): #{branch_universal_link_domains}\n"
|
365
|
-
end
|
366
|
-
end
|
367
|
-
rescue StandardError => e
|
368
|
-
report += " (Failed to open Info.plist: #{e.message})\n"
|
369
|
-
end
|
370
|
-
|
371
|
-
unless config.target.extension_target_type?
|
372
|
-
begin
|
373
|
-
domains = helper.domains_from_project config.configuration
|
374
|
-
report += " Universal Link domains (entitlements):\n"
|
375
|
-
domains.each do |domain|
|
376
|
-
report += " #{domain}\n"
|
377
|
-
end
|
378
|
-
rescue StandardError => e
|
379
|
-
report += " (Failed to get Universal Link domains from entitlements file: #{e.message})\n"
|
380
|
-
end
|
381
|
-
end
|
382
|
-
|
383
|
-
report += report_helper.report_imports
|
384
|
-
|
385
|
-
report
|
386
|
-
end
|
387
|
-
|
388
|
-
def load_settings_from_xcode
|
389
|
-
cmd = "#{base_xcodebuild_cmd} -scheme #{config.scheme}"
|
390
|
-
cmd += " -configuration #{config.configuration} -sdk #{config.sdk} -showBuildSettings"
|
391
|
-
@xcodebuild_showbuildsettings_output = ""
|
392
|
-
@xcode_settings = {}
|
393
|
-
Open3.popen2e(cmd) do |stdin, output, thread|
|
394
|
-
while (line = output.gets)
|
395
|
-
@xcodebuild_showbuildsettings_output += line
|
396
|
-
line.strip!
|
397
|
-
next unless (matches = /^(.+)\s+=\s+(.+)$/.match line)
|
398
|
-
@xcode_settings[matches[1]] = matches[2]
|
399
|
-
end
|
400
|
-
@xcodebuild_showbuildsettings_status = thread.value
|
401
|
-
return @xcodebuild_showbuildsettings_status.success?
|
402
|
-
end
|
87
|
+
def xcode_settings
|
88
|
+
Configuration::XcodeSettings.settings
|
403
89
|
end
|
404
90
|
end
|
405
91
|
end
|
@@ -2,3 +2,4 @@ require "branch_io_cli/configuration/configuration"
|
|
2
2
|
require "branch_io_cli/configuration/report_configuration"
|
3
3
|
require "branch_io_cli/configuration/setup_configuration"
|
4
4
|
require "branch_io_cli/configuration/validate_configuration"
|
5
|
+
require "branch_io_cli/configuration/xcode_settings"
|
@@ -13,7 +13,7 @@ module BranchIOCLI
|
|
13
13
|
attr_reader :xcodeproj
|
14
14
|
attr_reader :xcodeproj_path
|
15
15
|
attr_reader :target
|
16
|
-
|
16
|
+
attr_reader :podfile
|
17
17
|
attr_reader :podfile_path
|
18
18
|
attr_reader :cartfile_path
|
19
19
|
attr_reader :sdk_integration_mode
|
@@ -184,6 +184,31 @@ EOF
|
|
184
184
|
end
|
185
185
|
end
|
186
186
|
|
187
|
+
def pod_install_required?
|
188
|
+
# If this is set, its existence has been verified.
|
189
|
+
return false unless podfile_path
|
190
|
+
|
191
|
+
lockfile_path = "#{podfile_path}.lock"
|
192
|
+
manifest_path = File.expand_path "../Pods/Manifest.lock", podfile_path
|
193
|
+
|
194
|
+
return true unless File.exist?(lockfile_path) && File.exist?(manifest_path)
|
195
|
+
|
196
|
+
lockfile = Pod::Lockfile.from_file Pathname.new lockfile_path
|
197
|
+
manifest = Pod::Lockfile.from_file Pathname.new manifest_path
|
198
|
+
|
199
|
+
# diff the contents of Podfile.lock and Pods/Manifest.lock
|
200
|
+
# This is just what is done in the "[CP] Check Pods Manifest.lock" script build phase
|
201
|
+
# in a project using CocoaPods.
|
202
|
+
return true unless lockfile == manifest
|
203
|
+
|
204
|
+
# compare checksum of Podfile with checksum in Podfile.lock
|
205
|
+
# This is a good sanity check, but perhaps unnecessary. It means pod install
|
206
|
+
# has not been run since the Podfile was modified, which is probably an oversight.
|
207
|
+
return true unless lockfile.to_hash["PODFILE CHECKSUM"] == podfile.checksum
|
208
|
+
|
209
|
+
false
|
210
|
+
end
|
211
|
+
|
187
212
|
def uses_frameworks?
|
188
213
|
return nil unless podfile
|
189
214
|
target_definition = podfile.target_definition_list.find { |t| t.name == target.name }
|
@@ -214,6 +239,26 @@ EOF
|
|
214
239
|
app_delegate.file_ref.real_path.to_s
|
215
240
|
end
|
216
241
|
|
242
|
+
def messages_view_controller_path
|
243
|
+
return nil unless target.symbol_type == :messages_extension
|
244
|
+
|
245
|
+
all_paths = target.source_build_phase.files.map { |f| f.file_ref.real_path.to_s }
|
246
|
+
swift_paths = all_paths.grep(/\.swift$/)
|
247
|
+
|
248
|
+
# We're looking for the @interface declaration for a class that inherits from
|
249
|
+
# MSMessagesAppViewController. The target probably doesn't have a headers
|
250
|
+
# build phase. Include all .ms from the source build phase and any .h
|
251
|
+
# with the same root.
|
252
|
+
objc_paths = all_paths.grep(/\.m$/)
|
253
|
+
objc_paths += objc_paths.map { |p| p.sub(/\.m$/, '.h') }.select { |f| File.exist? f }
|
254
|
+
|
255
|
+
path = swift_paths.find { |f| /class.*:\s+MSMessagesAppViewController\s*{\n/m.match_file f } ||
|
256
|
+
objc_paths.find { |f| /@interface.*:\s+MSMessagesAppViewController/.match_file f }
|
257
|
+
|
258
|
+
# If we found a .h, patch the corresponding .m.
|
259
|
+
path && path.sub(/\.h$/, '.m')
|
260
|
+
end
|
261
|
+
|
217
262
|
# TODO: How many of these can vary by configuration?
|
218
263
|
|
219
264
|
def modules_enabled?
|
@@ -245,7 +290,8 @@ EOF
|
|
245
290
|
def branch_imports
|
246
291
|
return @branch_imports if @branch_imports
|
247
292
|
|
248
|
-
source_files =
|
293
|
+
source_files = target.source_build_phase.files.map { |f| f.file_ref.real_path.to_s }
|
294
|
+
source_files << bridging_header_path if bridging_header_path
|
249
295
|
@branch_imports = source_files.compact.map { |f| { f => branch_imports_from_file(f) } }.inject({}, :merge)
|
250
296
|
@branch_imports
|
251
297
|
end
|
@@ -1,3 +1,44 @@
|
|
1
|
+
require "plist"
|
2
|
+
require "xcodeproj"
|
3
|
+
|
4
|
+
module Xcodeproj
|
5
|
+
class Project
|
6
|
+
# Local override to allow for user schemes.
|
7
|
+
#
|
8
|
+
# Get list of shared and user schemes in project
|
9
|
+
#
|
10
|
+
# @param [String] path
|
11
|
+
# project path
|
12
|
+
#
|
13
|
+
# @return [Array]
|
14
|
+
#
|
15
|
+
def self.schemes(project_path)
|
16
|
+
base_dirs = [File.join(project_path, 'xcshareddata', 'xcschemes'),
|
17
|
+
File.join(project_path, 'xcuserdata', "#{ENV['USER']}.xcuserdatad", 'xcschemes')]
|
18
|
+
|
19
|
+
# Take any .xcscheme file from base_dirs
|
20
|
+
schemes = base_dirs.inject([]) { |memo, dir| memo + Dir[File.join dir, '*.xcscheme'] }
|
21
|
+
.map { |f| File.basename(f, '.xcscheme') }
|
22
|
+
|
23
|
+
# Include any scheme defined in the xcschememanagement.plist, if it exists.
|
24
|
+
base_dirs.map { |d| File.join d, 'xcschememanagement.plist' }
|
25
|
+
.select { |f| File.exist? f }.each do |plist_path|
|
26
|
+
plist = File.open(plist_path) { |f| ::Plist.parse_xml f }
|
27
|
+
scheme_user_state = plist["SchemeUserState"]
|
28
|
+
schemes += scheme_user_state.keys.map { |k| File.basename k, '.xcscheme' }
|
29
|
+
end
|
30
|
+
|
31
|
+
schemes.uniq!
|
32
|
+
if schemes.empty?
|
33
|
+
# Open the project, get all targets. Add one scheme per target.
|
34
|
+
project = self.open project_path
|
35
|
+
schemes += project.targets.reject(&:test_target_type?).map(&:name)
|
36
|
+
end
|
37
|
+
schemes
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
1
42
|
module BranchIOCLI
|
2
43
|
module Configuration
|
3
44
|
class ReportConfiguration < Configuration
|
@@ -8,6 +49,10 @@ module BranchIOCLI
|
|
8
49
|
attr_reader :report_path
|
9
50
|
attr_reader :sdk
|
10
51
|
|
52
|
+
def xcode_settings
|
53
|
+
XcodeSettings.settings
|
54
|
+
end
|
55
|
+
|
11
56
|
def validate_options
|
12
57
|
@clean = options.clean
|
13
58
|
@header_only = options.header_only
|
@@ -33,6 +78,24 @@ module BranchIOCLI
|
|
33
78
|
validate_buildfile_path(options.cartfile, "Cartfile") if sdk_integration_mode.nil?
|
34
79
|
end
|
35
80
|
|
81
|
+
# TODO: Collapse the following methods with support for formatting.
|
82
|
+
def report_configuration
|
83
|
+
<<EOF
|
84
|
+
Configuration:
|
85
|
+
|
86
|
+
Xcode workspace: #{workspace_path || '(none)'}
|
87
|
+
Xcode project: #{xcodeproj_path || '(none)'}
|
88
|
+
Scheme: #{scheme || '(none)'}
|
89
|
+
Target: #{target || '(none)'}
|
90
|
+
Configuration: #{configuration || '(none)'}
|
91
|
+
SDK: #{sdk}
|
92
|
+
Podfile: #{relative_path(podfile_path) || '(none)'}
|
93
|
+
Cartfile: #{relative_path(cartfile_path) || '(none)'}
|
94
|
+
Pod repo update: #{pod_repo_update.inspect}
|
95
|
+
Clean: #{clean.inspect}
|
96
|
+
EOF
|
97
|
+
end
|
98
|
+
|
36
99
|
def log
|
37
100
|
super
|
38
101
|
say <<EOF
|
@@ -189,8 +252,7 @@ EOF
|
|
189
252
|
|
190
253
|
unless scheme_path
|
191
254
|
# Look for a local scheme
|
192
|
-
user =
|
193
|
-
user ||= ENV["USER"] || ENV["LOGNAME"]
|
255
|
+
user = ENV["USER"]
|
194
256
|
xcuserdata_path = File.join project_path, "xcuserdata", "#{user}.xcuserdatad", "xcschemes", "#{@scheme}.xcscheme"
|
195
257
|
scheme_path = xcuserdata_path if File.exist?(xcuserdata_path)
|
196
258
|
end
|
@@ -222,6 +284,97 @@ EOF
|
|
222
284
|
|
223
285
|
@configuration = xcscheme.launch_action.build_configuration
|
224
286
|
end
|
287
|
+
|
288
|
+
def branch_version
|
289
|
+
version_from_podfile_lock ||
|
290
|
+
version_from_cartfile_resolved ||
|
291
|
+
version_from_branch_framework ||
|
292
|
+
version_from_bnc_config_m
|
293
|
+
end
|
294
|
+
|
295
|
+
def requirement_from_podfile
|
296
|
+
return nil unless podfile_path
|
297
|
+
podfile = File.read podfile_path
|
298
|
+
matches = /\n?\s*pod\s+("Branch"|'Branch').*?\n/m.match podfile
|
299
|
+
matches ? matches[0].strip : nil
|
300
|
+
end
|
301
|
+
|
302
|
+
def requirement_from_cartfile
|
303
|
+
return nil unless cartfile_path
|
304
|
+
cartfile = File.read cartfile_path
|
305
|
+
matches = %r{^git(hub\s+"|\s+"https://github.com/)BranchMetrics/(ios-branch-deep-linking|iOS-Deferred-Deep-Linking-SDK.*?).*?\n}m.match cartfile
|
306
|
+
matches ? matches[0].strip : nil
|
307
|
+
end
|
308
|
+
|
309
|
+
def version_from_podfile_lock
|
310
|
+
return nil unless podfile_path && File.exist?("#{podfile_path}.lock")
|
311
|
+
podfile_lock = Pod::Lockfile.from_file Pathname.new "#{podfile_path}.lock"
|
312
|
+
version = podfile_lock.version("Branch") || podfile_lock.version("Branch-SDK")
|
313
|
+
|
314
|
+
version ? "#{version} [Podfile.lock]" : nil
|
315
|
+
end
|
316
|
+
|
317
|
+
def version_from_cartfile_resolved
|
318
|
+
return nil unless cartfile_path && File.exist?("#{cartfile_path}.resolved")
|
319
|
+
cartfile_resolved = File.read "#{cartfile_path}.resolved"
|
320
|
+
|
321
|
+
# Matches:
|
322
|
+
# git "https://github.com/BranchMetrics/ios-branch-deep-linking"
|
323
|
+
# git "https://github.com/BranchMetrics/ios-branch-deep-linking/"
|
324
|
+
# git "https://github.com/BranchMetrics/iOS-Deferred-Deep-Linking-SDK"
|
325
|
+
# git "https://github.com/BranchMetrics/iOS-Deferred-Deep-Linking-SDK/"
|
326
|
+
# github "BranchMetrics/ios-branch-deep-linking"
|
327
|
+
# github "BranchMetrics/ios-branch-deep-linking/"
|
328
|
+
# github "BranchMetrics/iOS-Deferred-Deep-Linking-SDK"
|
329
|
+
# github "BranchMetrics/iOS-Deferred-Deep-Linking-SDK/"
|
330
|
+
matches = %r{(ios-branch-deep-linking|iOS-Deferred-Deep-Linking-SDK)/?" "(\d+\.\d+\.\d+)"}m.match cartfile_resolved
|
331
|
+
return nil unless matches
|
332
|
+
version = matches[2]
|
333
|
+
"#{version} [Cartfile.resolved]"
|
334
|
+
end
|
335
|
+
|
336
|
+
def version_from_branch_framework
|
337
|
+
framework = target.frameworks_build_phase.files.find { |f| f.file_ref.path =~ /Branch.framework$/ }
|
338
|
+
return nil unless framework
|
339
|
+
|
340
|
+
if framework.file_ref.isa == "PBXFileReference"
|
341
|
+
project_path = relative_path(config.xcodeproj_path)
|
342
|
+
framework_path = framework.file_ref.real_path
|
343
|
+
elsif framework.file_ref.isa == "PBXReferenceProxy" && xcode_settings
|
344
|
+
project_path = relative_path framework.file_ref.remote_ref.proxied_object.project.path
|
345
|
+
framework_path = File.expand_path framework.file_ref.path, xcode_settings[framework.file_ref.source_tree]
|
346
|
+
end
|
347
|
+
info_plist_path = File.join framework_path.to_s, "Info.plist"
|
348
|
+
return nil unless File.exist? info_plist_path
|
349
|
+
|
350
|
+
require "cfpropertylist"
|
351
|
+
|
352
|
+
raw_info_plist = CFPropertyList::List.new file: info_plist_path
|
353
|
+
info_plist = CFPropertyList.native_types raw_info_plist.value
|
354
|
+
version = info_plist["CFBundleVersion"]
|
355
|
+
return nil unless version
|
356
|
+
"#{version} [Branch.framework/Info.plist:#{project_path}]"
|
357
|
+
end
|
358
|
+
|
359
|
+
def version_from_bnc_config_m(project = xcodeproj)
|
360
|
+
# Look for BNCConfig.m in embedded source
|
361
|
+
bnc_config_m_ref = project.files.find { |f| f.path =~ /BNCConfig\.m$/ }
|
362
|
+
unless bnc_config_m_ref
|
363
|
+
subprojects = project.files.select { |f| f.path =~ /\.xcodeproj$/ }
|
364
|
+
subprojects.each do |subproject|
|
365
|
+
p = Xcodeproj::Project.open subproject.real_path
|
366
|
+
version = version_from_bnc_config_m p
|
367
|
+
return version if version
|
368
|
+
end
|
369
|
+
end
|
370
|
+
|
371
|
+
return nil unless bnc_config_m_ref
|
372
|
+
bnc_config_m = File.read bnc_config_m_ref.real_path
|
373
|
+
matches = /BNC_SDK_VERSION\s+=\s+@"(\d+\.\d+\.\d+)"/m.match bnc_config_m
|
374
|
+
return nil unless matches
|
375
|
+
version = matches[1]
|
376
|
+
"#{version} [BNCConfig.m:#{relative_path project.path}]"
|
377
|
+
end
|
225
378
|
end
|
226
379
|
end
|
227
380
|
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require "open3"
|
2
|
+
require "shellwords"
|
3
|
+
|
4
|
+
module BranchIOCLI
|
5
|
+
module Configuration
|
6
|
+
class XcodeSettings
|
7
|
+
class << self
|
8
|
+
def settings
|
9
|
+
return @settings if @settings
|
10
|
+
@settings = self.new
|
11
|
+
@settings
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize
|
16
|
+
load_settings_from_xcode
|
17
|
+
end
|
18
|
+
|
19
|
+
def valid?
|
20
|
+
@xcodebuild_showbuildsettings_status.success?
|
21
|
+
end
|
22
|
+
|
23
|
+
def config
|
24
|
+
Configuration.current
|
25
|
+
end
|
26
|
+
|
27
|
+
def [](key)
|
28
|
+
@xcode_settings[key]
|
29
|
+
end
|
30
|
+
|
31
|
+
def xcodebuild_cmd
|
32
|
+
cmd = "xcodebuild"
|
33
|
+
cmd = "#{cmd} -project #{Shellwords.escape config.xcodeproj_path}"
|
34
|
+
cmd += " -target #{Shellwords.escape config.target.name}"
|
35
|
+
cmd += " -configuration #{Shellwords.escape config.configuration}"
|
36
|
+
cmd += " -sdk #{Shellwords.escape config.sdk}"
|
37
|
+
cmd += " -showBuildSettings"
|
38
|
+
cmd
|
39
|
+
end
|
40
|
+
|
41
|
+
def load_settings_from_xcode
|
42
|
+
@xcodebuild_showbuildsettings_output = ""
|
43
|
+
@xcode_settings = {}
|
44
|
+
Open3.popen2e(xcodebuild_cmd) do |stdin, output, thread|
|
45
|
+
while (line = output.gets)
|
46
|
+
@xcodebuild_showbuildsettings_output += line
|
47
|
+
line.strip!
|
48
|
+
next unless (matches = /^(.+)\s+=\s+(.+)$/.match line)
|
49
|
+
@xcode_settings[matches[1]] = matches[2]
|
50
|
+
end
|
51
|
+
@xcodebuild_showbuildsettings_status = thread.value
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def log_xcodebuild_showbuildsettings(report = STDOUT)
|
56
|
+
report.write "$ #{xcodebuild_cmd}\n\n"
|
57
|
+
report.write @xcodebuild_showbuildsettings_output
|
58
|
+
if valid?
|
59
|
+
report.write "Success.\n\n"
|
60
|
+
else
|
61
|
+
report.write "#{@xcodebuild_showbuildsettings_status}.\n\n"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -345,11 +345,13 @@ module BranchIOCLI
|
|
345
345
|
if target_name
|
346
346
|
target = project.targets.find { |t| t.name == target_name }
|
347
347
|
raise "Target #{target} not found" if target.nil?
|
348
|
+
elsif config.respond_to?(:scheme) && project.targets.map(&:name).include?(config.scheme)
|
349
|
+
# Return a target with the same name as the scheme, if there is one.
|
350
|
+
target = project.targets.find { |t| t.name == config.scheme }
|
348
351
|
else
|
349
352
|
# find the first application target
|
350
|
-
|
351
|
-
|
352
|
-
raise "No application target found" if target.nil?
|
353
|
+
target = project.targets.find { |t| t.name == File.basename(project.path, '.xcodeproj') } ||
|
354
|
+
project.targets.select { |t| !t.extension_target_type? && !t.test_target_type? }.first
|
353
355
|
end
|
354
356
|
target
|
355
357
|
end
|
@@ -1,6 +1,13 @@
|
|
1
1
|
module BranchIOCLI
|
2
2
|
module Helper
|
3
|
-
class CommandError < RuntimeError
|
3
|
+
class CommandError < RuntimeError
|
4
|
+
attr_reader :status
|
5
|
+
def initialize(args)
|
6
|
+
message, status = *args
|
7
|
+
super message
|
8
|
+
@status = status
|
9
|
+
end
|
10
|
+
end
|
4
11
|
|
5
12
|
module Methods
|
6
13
|
# Execute a shell command with reporting.
|
@@ -16,7 +23,7 @@ module BranchIOCLI
|
|
16
23
|
# :output: [IO] An optional IO object to receive stdout and stderr from the command
|
17
24
|
def sh(command, output = STDOUT)
|
18
25
|
status = output.log_command command
|
19
|
-
raise CommandError, %{Error executing "#{command}": #{status}.} unless status.success?
|
26
|
+
raise CommandError, [%{Error executing "#{command}": #{status}.}, status] unless status.success?
|
20
27
|
end
|
21
28
|
end
|
22
29
|
end
|
@@ -185,6 +185,39 @@ module BranchIOCLI
|
|
185
185
|
patch.apply app_delegate_objc_path
|
186
186
|
end
|
187
187
|
|
188
|
+
def patch_messages_view_controller
|
189
|
+
path = config.messages_view_controller_path
|
190
|
+
|
191
|
+
patch_name = "messages_did_become_active_"
|
192
|
+
case path
|
193
|
+
when nil
|
194
|
+
return false
|
195
|
+
when /\.swift$/
|
196
|
+
return false if /branch.*initSession/m.match_file path
|
197
|
+
|
198
|
+
unless config.bridging_header_required?
|
199
|
+
load_patch(:swift_import).apply path
|
200
|
+
end
|
201
|
+
|
202
|
+
is_new_method = !/didBecomeActive\(with.*?\{[^\n]*\n/m.match_file(path)
|
203
|
+
patch_name += "#{is_new_method ? 'new_' : ''}swift"
|
204
|
+
else
|
205
|
+
return false if %r{^\s+#import\s+<Branch/Branch.h>|^\s+@import\s+Branch\s*;}.match_file(path)
|
206
|
+
|
207
|
+
load_patch(:objc_import).apply path
|
208
|
+
|
209
|
+
is_new_method = !/didBecomeActiveWithConversation.*?\{[^\n]*\n/m.match_file(path)
|
210
|
+
patch_name += "#{is_new_method ? 'new_' : ''}objc"
|
211
|
+
end
|
212
|
+
|
213
|
+
say "Patching #{path}"
|
214
|
+
|
215
|
+
load_patch(patch_name).apply path, binding: binding
|
216
|
+
|
217
|
+
helper.add_change(path)
|
218
|
+
true
|
219
|
+
end
|
220
|
+
|
188
221
|
def patch_podfile(podfile_path)
|
189
222
|
target_definition = config.podfile.target_definitions[config.target.name]
|
190
223
|
raise "Target #{config.target.name} not found in Podfile" unless target_definition
|
@@ -238,6 +271,7 @@ module BranchIOCLI
|
|
238
271
|
# is in Swift or Objective-C.
|
239
272
|
patch_bridging_header if config.bridging_header_required?
|
240
273
|
patch_app_delegate_swift(xcodeproj) || patch_app_delegate_objc(xcodeproj)
|
274
|
+
patch_messages_view_controller
|
241
275
|
end
|
242
276
|
end
|
243
277
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require "plist"
|
2
|
+
require "shellwords"
|
1
3
|
require "branch_io_cli/configuration/configuration"
|
2
4
|
|
3
5
|
module BranchIOCLI
|
@@ -17,6 +19,168 @@ module BranchIOCLI
|
|
17
19
|
def config
|
18
20
|
Configuration::Configuration.current
|
19
21
|
end
|
22
|
+
|
23
|
+
def helper
|
24
|
+
Helper::BranchHelper
|
25
|
+
end
|
26
|
+
|
27
|
+
def xcode_settings
|
28
|
+
Configuration::XcodeSettings.settings
|
29
|
+
end
|
30
|
+
|
31
|
+
def base_xcodebuild_cmd
|
32
|
+
cmd = "xcodebuild"
|
33
|
+
if config.workspace_path
|
34
|
+
cmd = "#{cmd} -workspace #{Shellwords.escape config.workspace_path}"
|
35
|
+
else
|
36
|
+
cmd = "#{cmd} -project #{Shellwords.escape config.xcodeproj_path}"
|
37
|
+
end
|
38
|
+
cmd
|
39
|
+
end
|
40
|
+
|
41
|
+
# rubocop: disable Metrics/PerceivedComplexity
|
42
|
+
def report_header
|
43
|
+
header = "cocoapods-core: #{Pod::CORE_VERSION}\n"
|
44
|
+
|
45
|
+
header += `xcodebuild -version`
|
46
|
+
header += "SDK: #{xcode_settings['SDK_NAME']}\n" if xcode_settings
|
47
|
+
|
48
|
+
bundle_identifier = helper.expanded_build_setting config.target, "PRODUCT_BUNDLE_IDENTIFIER", config.configuration
|
49
|
+
dev_team = helper.expanded_build_setting config.target, "DEVELOPMENT_TEAM", config.configuration
|
50
|
+
infoplist_path = helper.expanded_build_setting config.target, "INFOPLIST_FILE", config.configuration
|
51
|
+
entitlements_path = helper.expanded_build_setting config.target, "CODE_SIGN_ENTITLEMENTS", config.configuration
|
52
|
+
|
53
|
+
header += "\nTarget #{config.target.name}:\n"
|
54
|
+
header += " Bundle identifier: #{bundle_identifier || '(none)'}\n"
|
55
|
+
header += " Development team: #{dev_team || '(none)'}\n"
|
56
|
+
header += " Deployment target: #{config.target.deployment_target}\n"
|
57
|
+
header += " Modules #{config.modules_enabled? ? '' : 'not '}enabled\n"
|
58
|
+
header += " Swift #{config.swift_version}\n" if config.swift_version
|
59
|
+
header += " Bridging header: #{config.relative_path(config.bridging_header_path)}\n" if config.bridging_header_path
|
60
|
+
header += " Info.plist: #{config.relative_path(infoplist_path) || '(none)'}\n"
|
61
|
+
header += " Entitlements file: #{config.relative_path(entitlements_path) || '(none)'}\n"
|
62
|
+
|
63
|
+
if config.podfile_path
|
64
|
+
begin
|
65
|
+
cocoapods_version = `pod --version`.chomp
|
66
|
+
rescue Errno::ENOENT
|
67
|
+
header += "\n(pod command not found)\n"
|
68
|
+
end
|
69
|
+
|
70
|
+
if File.exist?("#{config.podfile_path}.lock")
|
71
|
+
podfile_lock = Pod::Lockfile.from_file Pathname.new "#{config.podfile_path}.lock"
|
72
|
+
end
|
73
|
+
|
74
|
+
if cocoapods_version || podfile_lock
|
75
|
+
header += "\nUsing CocoaPods v. "
|
76
|
+
if cocoapods_version
|
77
|
+
header += "#{cocoapods_version} (CLI) "
|
78
|
+
end
|
79
|
+
if podfile_lock
|
80
|
+
header += "#{podfile_lock.cocoapods_version} (Podfile.lock)"
|
81
|
+
end
|
82
|
+
header += "\n"
|
83
|
+
end
|
84
|
+
|
85
|
+
target_definition = config.podfile.target_definitions[config.target.name]
|
86
|
+
if target_definition
|
87
|
+
branch_deps = target_definition.dependencies.select { |p| p.name =~ %r{^(Branch|Branch-SDK)(/.*)?$} }
|
88
|
+
header += "Podfile target #{target_definition.name}:"
|
89
|
+
header += "\n use_frameworks!" if target_definition.uses_frameworks?
|
90
|
+
header += "\n platform: #{target_definition.platform}"
|
91
|
+
header += "\n build configurations: #{target_definition.build_configurations}"
|
92
|
+
header += "\n inheritance: #{target_definition.inheritance}"
|
93
|
+
branch_deps.each do |dep|
|
94
|
+
header += "\n pod '#{dep.name}', '#{dep.requirement}'"
|
95
|
+
header += ", #{dep.external_source}" if dep.external_source
|
96
|
+
header += "\n"
|
97
|
+
end
|
98
|
+
else
|
99
|
+
header += "Target #{config.target.name.inspect} not found in Podfile.\n"
|
100
|
+
end
|
101
|
+
|
102
|
+
header += "\npod install #{config.pod_install_required? ? '' : 'not '}required.\n"
|
103
|
+
end
|
104
|
+
|
105
|
+
if config.cartfile_path
|
106
|
+
begin
|
107
|
+
carthage_version = `carthage version`.chomp
|
108
|
+
header += "\nUsing Carthage v. #{carthage_version}\n"
|
109
|
+
rescue Errno::ENOENT
|
110
|
+
header += "\n(carthage command not found)\n"
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
cartfile_requirement = config.requirement_from_cartfile
|
115
|
+
header += "\nFrom Cartfile:\n#{cartfile_requirement}\n" if cartfile_requirement
|
116
|
+
|
117
|
+
version = config.branch_version
|
118
|
+
if version
|
119
|
+
header += "\nBranch SDK v. #{version}\n"
|
120
|
+
else
|
121
|
+
header += "\nBranch SDK not found.\n"
|
122
|
+
end
|
123
|
+
|
124
|
+
header += "\n#{branch_report}"
|
125
|
+
|
126
|
+
header
|
127
|
+
end
|
128
|
+
# rubocop: enable Metrics/PerceivedComplexity
|
129
|
+
|
130
|
+
# String containing information relevant to Branch setup
|
131
|
+
def branch_report
|
132
|
+
infoplist_path = helper.expanded_build_setting config.target, "INFOPLIST_FILE", config.configuration
|
133
|
+
infoplist_path = File.expand_path infoplist_path, File.dirname(config.xcodeproj_path)
|
134
|
+
|
135
|
+
report = "Branch configuration:\n"
|
136
|
+
|
137
|
+
begin
|
138
|
+
info_plist = File.open(infoplist_path) { |f| Plist.parse_xml f }
|
139
|
+
branch_key = info_plist["branch_key"]
|
140
|
+
report += " Branch key(s) (Info.plist):\n"
|
141
|
+
if branch_key.kind_of? Hash
|
142
|
+
branch_key.each_key do |key|
|
143
|
+
resolved_key = helper.expand_build_settings branch_key[key], config.target, config.configuration
|
144
|
+
report += " #{key.capitalize}: #{resolved_key}\n"
|
145
|
+
end
|
146
|
+
elsif branch_key
|
147
|
+
resolved_key = helper.expand_build_settings branch_key, config.target, config.configuration
|
148
|
+
report += " #{resolved_key}\n"
|
149
|
+
else
|
150
|
+
report += " (none found)\n"
|
151
|
+
end
|
152
|
+
|
153
|
+
branch_universal_link_domains = info_plist["branch_universal_link_domains"]
|
154
|
+
if branch_universal_link_domains
|
155
|
+
if branch_universal_link_domains.kind_of? Array
|
156
|
+
report += " branch_universal_link_domains (Info.plist):\n"
|
157
|
+
branch_universal_link_domains.each do |domain|
|
158
|
+
report += " #{domain}\n"
|
159
|
+
end
|
160
|
+
else
|
161
|
+
report += " branch_universal_link_domains (Info.plist): #{branch_universal_link_domains}\n"
|
162
|
+
end
|
163
|
+
end
|
164
|
+
rescue StandardError => e
|
165
|
+
report += " (Failed to open Info.plist: #{e.message})\n"
|
166
|
+
end
|
167
|
+
|
168
|
+
unless config.target.extension_target_type?
|
169
|
+
begin
|
170
|
+
domains = helper.domains_from_project config.configuration
|
171
|
+
report += " Universal Link domains (entitlements):\n"
|
172
|
+
domains.each do |domain|
|
173
|
+
report += " #{domain}\n"
|
174
|
+
end
|
175
|
+
rescue StandardError => e
|
176
|
+
report += " (Failed to get Universal Link domains from entitlements file: #{e.message})\n"
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
report += report_imports
|
181
|
+
|
182
|
+
report
|
183
|
+
end
|
20
184
|
end
|
21
185
|
end
|
22
186
|
end
|
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.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Branch
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-11-
|
12
|
+
date: 2017-11-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: CFPropertyList
|
@@ -256,6 +256,8 @@ files:
|
|
256
256
|
- lib/assets/patches/ContinueUserActivityNew.swift
|
257
257
|
- lib/assets/patches/DidFinishLaunching.m
|
258
258
|
- lib/assets/patches/DidFinishLaunching.swift
|
259
|
+
- lib/assets/patches/MessagesDidBecomeActive.m
|
260
|
+
- lib/assets/patches/MessagesDidBecomeActive.swift
|
259
261
|
- lib/assets/patches/OpenUrl.m
|
260
262
|
- lib/assets/patches/OpenUrl.swift
|
261
263
|
- lib/assets/patches/OpenUrlNew.m
|
@@ -271,6 +273,10 @@ files:
|
|
271
273
|
- lib/assets/patches/did_finish_launching_new_swift.yml
|
272
274
|
- lib/assets/patches/did_finish_launching_objc.yml
|
273
275
|
- lib/assets/patches/did_finish_launching_swift.yml
|
276
|
+
- lib/assets/patches/messages_did_become_active_new_objc.yml
|
277
|
+
- lib/assets/patches/messages_did_become_active_new_swift.yml
|
278
|
+
- lib/assets/patches/messages_did_become_active_objc.yml
|
279
|
+
- lib/assets/patches/messages_did_become_active_swift.yml
|
274
280
|
- lib/assets/patches/objc_import.yml
|
275
281
|
- lib/assets/patches/objc_import_at_end.yml
|
276
282
|
- lib/assets/patches/objc_import_include_guard.yml
|
@@ -293,6 +299,7 @@ files:
|
|
293
299
|
- lib/branch_io_cli/configuration/report_configuration.rb
|
294
300
|
- lib/branch_io_cli/configuration/setup_configuration.rb
|
295
301
|
- lib/branch_io_cli/configuration/validate_configuration.rb
|
302
|
+
- lib/branch_io_cli/configuration/xcode_settings.rb
|
296
303
|
- lib/branch_io_cli/core_ext.rb
|
297
304
|
- lib/branch_io_cli/core_ext/io.rb
|
298
305
|
- lib/branch_io_cli/core_ext/regexp.rb
|