branch_io_cli 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6ed6a08fd41a779e66e95b3d4bbfd60b73f9f1a7
4
- data.tar.gz: 86d0ab68a447fa963a9bb40810aec4c9e7a54d13
3
+ metadata.gz: 9adda8f92100e01cd272fa97fe2bf8b71db6b664
4
+ data.tar.gz: c91ec03d311711ea448aec62ffa1db6f1f401e77
5
5
  SHA512:
6
- metadata.gz: 6853fe36957e1364ee1d3cfabfc43126d49570c8799838648619ddba431f62a0ddab9de3bdb641a9907d5f48d2fd3968226cb91b7e2001b65496dafdc5629ba2
7
- data.tar.gz: f37d61ba24b28fb17663d2ae71d7c38c800458fb58c12fb68ef2381e4e243c4688936b5ee4a9d16cfe1d57bfa87378d9ed24ab37ee04840bc3167974d1068d69
6
+ metadata.gz: 3ce717958b072775a9fbd789c249c23a80972ba8fe45cd2a546074d03b2b019d9fa6fdc2a580539193abe289579470617db34d7a46e8d7a396b30c4d6cbe7325
7
+ data.tar.gz: 84a1f6ef67c575e34c31c9306eeb62aea5858bf3005d7990769d5eba1bc8e4adbcdaa3561aca91cf4324b008a3d0114cefc049b9693e0ba704b649320cc054ab
data/README.md CHANGED
@@ -46,8 +46,8 @@ the project location using the `--xcodeproj` option.
46
46
  If a Podfile or Cartfile is detected, the Branch SDK will be added to the relevant
47
47
  configuration file and the dependencies updated to include the Branch framework.
48
48
  This behavior may be suppressed using `--no_add_sdk`. If no Podfile or Cartfile
49
- is found, the SDK dependency must be added manually. This will improve in a future
50
- release.
49
+ is found, and Branch.framework is not already among the project's dependencies,
50
+ you will be prompted for a number of choices.
51
51
 
52
52
  By default, all supplied Universal Link domains are validated. If validation passes,
53
53
  the setup continues. If validation fails, no further action is taken. Suppress
@@ -25,8 +25,8 @@ the project location using the <%= color('--xcodeproj', BOLD) %> option.
25
25
  If a Podfile or Cartfile is detected, the Branch SDK will be added to the relevant
26
26
  configuration file and the dependencies updated to include the Branch framework.
27
27
  This behavior may be suppressed using <%= color('--no_add_sdk', BOLD) %>. If no Podfile or Cartfile
28
- is found, the SDK dependency must be added manually. This will improve in a future
29
- release.
28
+ is found, and Branch.framework is not already among the project's dependencies,
29
+ you will be prompted for a number of choices.
30
30
 
31
31
  By default, all supplied Universal Link domains are validated. If validation passes,
32
32
  the setup continues. If validation fails, no further action is taken. Suppress
@@ -189,20 +189,18 @@ module BranchIOCLI
189
189
  @podfile_path = File.expand_path "../Podfile", @xcodeproj_path
190
190
  target = BranchHelper.target_from_project @xcodeproj, options.target
191
191
 
192
- File.open(@podfile_path, "w") do |file|
193
- file.write <<EOF
194
- platform :ios, "#{target.deployment_target}"
195
-
196
- pod "Branch"
197
-
198
- #{@xcodeproj.targets.map { |t| "target \"#{t.name}\"" }.join("\n")}
199
- EOF
200
- end
201
-
202
- command = "pod install"
203
- command += " --repo-update" unless options.no_pod_repo_update
192
+ install_command = "pod install"
193
+ install_command += " --repo-update" unless options.no_pod_repo_update
204
194
  Dir.chdir(File.dirname(@podfile_path)) do
205
- system command
195
+ system "pod init"
196
+ BranchHelper.apply_patch(
197
+ files: @podfile_path,
198
+ regexp: /^(\s*)# Pods for #{target.name}$/,
199
+ mode: :append,
200
+ text: "\n\\1pod \"Branch\"",
201
+ global: false
202
+ )
203
+ system install_command
206
204
  end
207
205
 
208
206
  BranchHelper.add_change @podfile_path
@@ -309,6 +307,17 @@ EOF
309
307
  framework = frameworks_group.new_file "Branch.framework"
310
308
  target = BranchHelper.target_from_project @xcodeproj, options.target
311
309
  target.frameworks_build_phase.add_file_reference framework, true
310
+
311
+ # Make sure this is in the FRAMEWORK_SEARCH_PATHS
312
+ @xcodeproj.build_configurations.each do |config|
313
+ setting = config.build_settings["FRAMEWORK_SEARCH_PATHS"] || []
314
+ setting = [setting] if setting.kind_of? String
315
+ next if setting.any? { |p| p == "$(SRCROOT)" }
316
+
317
+ setting << "$(SRCROOT)"
318
+ config.build_settings["FRAMEWORK_SEARCH_PATHS"] = setting
319
+ end
320
+
312
321
  @xcodeproj.save
313
322
 
314
323
  BranchHelper.add_change File.expand_path "Branch.framework"
@@ -357,12 +357,14 @@ module BranchIOCLI
357
357
  mode: :prepend
358
358
  )
359
359
 
360
- # TODO: This is Swift 3. Support other versions, esp. 4.
361
- init_session_text = <<-EOF
360
+ init_session_text = ConfigurationHelper.keys.count <= 1 ? "" : <<EOF
362
361
  #if DEBUG
363
362
  Branch.setUseTestBranchKey(true)
364
363
  #endif
365
364
 
365
+ EOF
366
+
367
+ init_session_text += <<-EOF
366
368
  Branch.getInstance().initSession(launchOptions: launchOptions) {
367
369
  universalObject, linkProperties, error in
368
370
 
@@ -377,13 +379,29 @@ module BranchIOCLI
377
379
  mode: :append
378
380
  )
379
381
 
380
- unless app_delegate =~ /application:.*continueUserActivity:.*restorationHandler:/
382
+ if app_delegate =~ /application:.*continue userActivity:.*restorationHandler:/
383
+ # Add something to the top of the method
384
+ continue_user_activity_text = <<-EOF
385
+ // TODO: Adjust your method as you see fit.
386
+ if Branch.getInstance.continue(userActivity) {
387
+ return true
388
+ }
389
+
390
+ EOF
391
+
392
+ apply_patch(
393
+ files: app_delegate_swift_path,
394
+ regexp: /application:.*continue userActivity:.*restorationHandler:.*?\{.*?\n/m,
395
+ text: continue_user_activity_text,
396
+ mode: :append
397
+ )
398
+ else
381
399
  # Add the application:continueUserActivity:restorationHandler method if it does not exist
382
400
  continue_user_activity_text = <<-EOF
383
401
 
384
402
 
385
- func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
386
- return Branch.getInstance().continue(userActivity)
403
+ func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool {
404
+ return Branch.getInstance().continue(userActivity)
387
405
  }
388
406
  EOF
389
407
 
@@ -417,11 +435,14 @@ module BranchIOCLI
417
435
  mode: :prepend
418
436
  )
419
437
 
420
- init_session_text = <<-EOF
438
+ init_session_text = ConfigurationHelper.keys.count <= 1 ? "" : <<EOF
421
439
  #ifdef DEBUG
422
440
  [Branch setUseTestBranchKey:YES];
423
441
  #endif // DEBUG
424
442
 
443
+ EOF
444
+
445
+ init_session_text += <<-EOF
425
446
  [[Branch getInstance] initSessionWithLaunchOptions:launchOptions
426
447
  andRegisterDeepLinkHandlerUsingBranchUniversalObject:^(BranchUniversalObject *universalObject, BranchLinkProperties *linkProperties, NSError *error){
427
448
  // TODO: Route Branch links
@@ -435,7 +456,22 @@ module BranchIOCLI
435
456
  mode: :append
436
457
  )
437
458
 
438
- unless app_delegate =~ /application:.*continueUserActivity:.*restorationHandler:/
459
+ if app_delegate =~ /application:.*continueUserActivity:.*restorationHandler:/
460
+ continue_user_activity_text = <<-EOF
461
+ // TODO: Adjust your method as you see fit.
462
+ if ([[Branch getInstance] continueUserActivity:userActivity]) {
463
+ return YES;
464
+ }
465
+
466
+ EOF
467
+
468
+ apply_patch(
469
+ files: app_delegate_objc_path,
470
+ regexp: /application:.*continueUserActivity:.*restorationHandler:.*?\{.*?\n/m,
471
+ text: continue_user_activity_text,
472
+ mode: :append
473
+ )
474
+ else
439
475
  # Add the application:continueUserActivity:restorationHandler method if it does not exist
440
476
  continue_user_activity_text = <<-EOF
441
477
 
@@ -1,3 +1,3 @@
1
1
  module BranchIOCLI
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  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.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Branch