branch_io_cli 0.9.2 → 0.9.3

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
  SHA256:
3
- metadata.gz: 875f76682dccf962d868c7ac37b3e5aab590e9655af0fd2266267d56f87e9d2b
4
- data.tar.gz: 453b47d417a6014d219ee5154c395ed435bf136c647d0d5b31aee0f70096259f
3
+ metadata.gz: 2908cdd4340d1d0d43da1875c4e08c2e4f6e46b56836395aaf47f6d401834218
4
+ data.tar.gz: bcbfe15c402201a6a6594712b688ca5288a7c54d20a99a9aa0517c6264bbf220
5
5
  SHA512:
6
- metadata.gz: 1ec7fdaf5b83fd581c5712184082a738d7c07305a9a3ae8bb190ef793e29b99b2952e8ffd031f20d00d30c4b65dc2ad3f87efa6718bdef142bf3ab2775df1c8a
7
- data.tar.gz: 144f3cff5bdce88845a687d1f1b188fa1872bd229598b2a56f0c96660c34c1274864ee294f3aece2a795f3e9d45f97138d16eb80a19d2ba0bcbcf26d8540d176
6
+ metadata.gz: b9edff995284b5a31a39cf22bb02a198b775c35a072046d5c2527730e41055d1e1c3f8dc1d800e0d8768809b8f4b35524453cf2c7d4ce8da7a29491d97c340d4
7
+ data.tar.gz: 2ea56d6e150521ea6e956584fb0fc8f4c7774702746724eb6d94418840387a2ee0fa42ce2945a34e5d05daddcdb13d81a182e9775be8b99c2f5ad04110c4ec9a
@@ -19,7 +19,7 @@ _branch_io_complete()
19
19
  validate_opts="$global_opts -D --domains --xcodeproj --target"
20
20
 
21
21
  report_opts="$global_opts --xcodeproj --workspace --header-only --no-clean --scheme --target --configuration --sdk --out"
22
- report_opts="$global_opts --podfile --cartfile --no-pod-repo-update"
22
+ report_opts="$report_opts --podfile --cartfile --no-pod-repo-update"
23
23
 
24
24
  if [[ ${cur} == -* ]] ; then
25
25
  case "${cmd}" in
@@ -1,4 +1,4 @@
1
1
  // TODO: Adjust your method as you see fit.
2
- if Branch.getInstance.continue(userActivity) {
2
+ if Branch.getInstance().continue(userActivity) {
3
3
  return true
4
4
  }
@@ -1,2 +1,3 @@
1
+ regexp: '/\n\s*@end[^@]*\Z/m'
1
2
  mode: prepend
2
3
  text_file: ContinueUserActivityNew.m
@@ -1,2 +1,3 @@
1
+ regexp: '/\n\s*\}[^{}]*\Z/m'
1
2
  mode: prepend
2
3
  text_file: ContinueUserActivityNew.swift
@@ -1,2 +1,3 @@
1
+ regexp: '/application:.*continueUserActivity:.*restorationHandler:.*?\{.*?\n/m'
1
2
  mode: append
2
3
  text_file: ContinueUserActivity.m
@@ -1,2 +1,3 @@
1
+ regexp: '/application:.*continue userActivity:.*restorationHandler:.*?\{.*?\n/m'
1
2
  mode: append
2
3
  text_file: ContinueUserActivity.swift
@@ -0,0 +1,3 @@
1
+ regexp: '/^@implementation.*?\n/m'
2
+ mode: append
3
+ text_file: DidFinishLaunching.m
@@ -0,0 +1,3 @@
1
+ regexp: '/var\s+window\s?:\s?UIWindow\?.*?\n/m'
2
+ mode: append
3
+ text_file: DidFinishLaunching.swift
@@ -1,2 +1,3 @@
1
+ regexp: '/didFinishLaunchingWithOptions.*?\{[^\n]*\n/m'
1
2
  mode: append
2
3
  text_file: DidFinishLaunching.m
@@ -1,2 +1,3 @@
1
+ regexp: '/didFinishLaunchingWithOptions.*?\{[^\n]*\n/m'
1
2
  mode: append
2
3
  text_file: DidFinishLaunching.swift
@@ -1,2 +1,3 @@
1
+ regexp: '/\n\s*@end[^@]*\Z/m'
1
2
  mode: prepend
2
3
  text_file: OpenUrlNew.m
@@ -1,2 +1,3 @@
1
+ regexp: '/\n\s*\}[^{}]*\Z/m'
1
2
  mode: prepend
2
3
  text_file: OpenUrlNew.swift
@@ -1,2 +1,3 @@
1
+ regexp: '/application:.*openURL:.*options:.*?\{.*?\n/m'
1
2
  mode: append
2
3
  text_file: OpenUrl.m
@@ -1,2 +1,3 @@
1
+ regexp: '/application:.*openURL:.*sourceApplication:.*?\{.*?\n/m'
1
2
  mode: append
2
3
  text_file: OpenUrlSourceApplication.m
@@ -1,2 +1,3 @@
1
+ regexp: '/application.*open\s+url.*sourceApplication:.*?\{.*?\n/m'
1
2
  mode: append
2
3
  text_file: OpenUrlSourceApplication.swift
@@ -1,2 +1,3 @@
1
+ regexp: '/application.*open\s+url.*options:.*?\{.*?\n/m'
1
2
  mode: append
2
3
  text_file: OpenUrl.swift
@@ -118,7 +118,7 @@ EOF
118
118
  def version_from_podfile_lock
119
119
  return nil unless config.podfile_path && File.exist?("#{config.podfile_path}.lock")
120
120
  podfile_lock = Pod::Lockfile.from_file Pathname.new "#{config.podfile_path}.lock"
121
- version = podfile_lock.version "Branch"
121
+ version = podfile_lock.version("Branch") || podfile_lock.version("Branch-SDK")
122
122
 
123
123
  version ? "#{version} [Podfile.lock]" : nil
124
124
  end
@@ -246,17 +246,19 @@ EOF
246
246
 
247
247
  # Already verified existence.
248
248
  podfile = Pod::Podfile.from_file Pathname.new config.podfile_path
249
- target_definition = podfile.target_definition_list.find { |t| t.name == config.target.name }
249
+ target_definition = podfile.target_definitions[config.target.name]
250
250
  if target_definition
251
- branch_dep = target_definition.dependencies.find { |p| p.name == "Branch" }
251
+ branch_deps = target_definition.dependencies.select { |p| p.name =~ %r{^(Branch|Branch-SDK)(/.*)?$} }
252
252
  header += "Podfile target #{target_definition.name}:"
253
253
  header += "\n use_frameworks!" if target_definition.uses_frameworks?
254
254
  header += "\n platform: #{target_definition.platform}"
255
255
  header += "\n build configurations: #{target_definition.build_configurations}"
256
256
  header += "\n inheritance: #{target_definition.inheritance}"
257
- header += "\n pod 'Branch', '#{branch_dep.requirement}'" if branch_dep
258
- header += ", #{branch_dep.external_source}" if branch_dep && branch_dep.external_source
259
- header += "\n"
257
+ branch_deps.each do |dep|
258
+ header += "\n pod '#{dep.name}', '#{dep.requirement}'"
259
+ header += ", #{dep.external_source}" if dep.external_source
260
+ header += "\n"
261
+ end
260
262
  else
261
263
  header += "Target #{config.target.name.inspect} not found in Podfile.\n"
262
264
  end
@@ -13,7 +13,7 @@ module BranchIOCLI
13
13
  attr_reader :xcodeproj
14
14
  attr_reader :xcodeproj_path
15
15
  attr_reader :target
16
- attr_reader :podfile
16
+ attr_accessor :podfile
17
17
  attr_reader :podfile_path
18
18
  attr_reader :cartfile_path
19
19
  attr_reader :sdk_integration_mode
@@ -187,7 +187,6 @@ module BranchIOCLI
187
187
  return if !options.add_sdk || sdk_integration_mode
188
188
 
189
189
  # If no CocoaPods or Carthage, check to see if the framework is linked.
190
- target = helper.target_from_project xcodeproj, options.target
191
190
  return if target.frameworks_build_phase.files.map(&:file_ref).map(&:path).any? { |p| p =~ /Branch.framework$/ }
192
191
 
193
192
  # --podfile, --cartfile not specified. No Podfile found. No Cartfile found. No Branch.framework in project.
@@ -1,3 +1,4 @@
1
+ require "cocoapods-core"
1
2
  require "json"
2
3
  require "net/http"
3
4
  require "openssl"
@@ -402,6 +403,9 @@ module BranchIOCLI
402
403
  mode: :append,
403
404
  text: "\n\\1pod \"Branch\""
404
405
  ).apply podfile_path
406
+ # Store a Pod::Podfile representation of this file.
407
+ # TODO: Might want to move this to Configuration.
408
+ config.podfile = Pod::Podfile.from_file Pathname.new "Podfile"
405
409
  sh install_command
406
410
  end
407
411
 
@@ -58,8 +58,10 @@ module BranchIOCLI
58
58
 
59
59
  app_delegate = File.read app_delegate_swift_path
60
60
 
61
- # Can't check for the import here, since there may be a bridging header.
62
- return false if app_delegate =~ /Branch\.initSession/
61
+ # Can't just check for the import here, since there may be a bridging header.
62
+ # This may match branch.initSession (if the Branch instance is stored) or
63
+ # Branch.getInstance().initSession, etc.
64
+ return false if app_delegate =~ /(import\s+branch|branch\.*initsession)/i
63
65
 
64
66
  unless config.bridging_header_required?
65
67
  load_patch(:swift_import).apply app_delegate_swift_path
@@ -99,14 +101,11 @@ module BranchIOCLI
99
101
  def patch_did_finish_launching_method_swift(app_delegate_swift_path)
100
102
  app_delegate_swift = File.read app_delegate_swift_path
101
103
 
102
- patch = load_patch(:did_finish_launching_swift)
103
104
  is_new_method = app_delegate_swift !~ /didFinishLaunching[^\n]+?\{/m
104
105
  if is_new_method
105
- # method not present. add entire method
106
- patch.regexp = /var\s+window\s?:\s?UIWindow\?.*?\n/m
106
+ patch = load_patch :did_finish_launching_new_swift
107
107
  else
108
- # method already present
109
- patch.regexp = /didFinishLaunchingWithOptions.*?\{[^\n]*\n/m
108
+ patch = load_patch :did_finish_launching_swift
110
109
  end
111
110
  patch.apply app_delegate_swift_path, binding: binding
112
111
  end
@@ -114,105 +113,85 @@ module BranchIOCLI
114
113
  def patch_did_finish_launching_method_objc(app_delegate_objc_path)
115
114
  app_delegate_objc = File.read app_delegate_objc_path
116
115
 
117
- patch = load_patch(:did_finish_launching_objc)
118
116
  is_new_method = app_delegate_objc !~ /didFinishLaunchingWithOptions/m
119
117
  if is_new_method
120
- # method does not exist. add it.
121
- patch.regexp = /^@implementation.*?\n/m
118
+ patch = load_patch :did_finish_launching_new_objc
122
119
  else
123
- # method exists. patch it.
124
- patch.regexp = /didFinishLaunchingWithOptions.*?\{[^\n]*\n/m
120
+ patch = load_patch :did_finish_launching_objc
125
121
  end
126
122
  patch.apply app_delegate_objc_path, binding: binding
127
123
  end
128
124
 
129
125
  def patch_open_url_method_swift(app_delegate_swift_path)
130
126
  app_delegate_swift = File.read app_delegate_swift_path
131
- patch_name = "open_url_"
127
+
132
128
  if app_delegate_swift =~ /application.*open\s+url.*options/
133
129
  # Has application:openURL:options:
134
- patch_name += "swift"
135
- patch = load_patch patch_name
136
- patch.regexp = /application.*open\s+url.*options:.*?\{.*?\n/m
130
+ patch = load_patch :open_url_swift
137
131
  elsif app_delegate_swift =~ /application.*open\s+url.*sourceApplication/
138
132
  # Has application:openURL:sourceApplication:annotation:
139
133
  # TODO: This method is deprecated.
140
- patch_name += "source_application_swift"
141
- patch = load_patch patch_name
142
- patch.regexp = /application.*open\s+url.*sourceApplication:.*?\{.*?\n/m
134
+ patch = load_patch :open_url_source_application_swift
143
135
  else
144
136
  # Has neither
145
- patch_name += "new_swift"
146
- patch = load_patch patch_name
147
- patch.regexp = /\n\s*\}[^{}]*\Z/m
137
+ patch = load_patch :open_url_new_swift
148
138
  end
149
139
  patch.apply app_delegate_swift_path
150
140
  end
151
141
 
152
142
  def patch_continue_user_activity_method_swift(app_delegate_swift_path)
153
- app_delegate = File.read app_delegate_swift_path
154
- patch_name = "continue_user_activity_"
155
- if app_delegate =~ /application:.*continue userActivity:.*restorationHandler:/
156
- # Add something to the top of the method
157
- patch_name += "swift"
158
- patch = load_patch patch_name
159
- patch.regexp = /application:.*continue userActivity:.*restorationHandler:.*?\{.*?\n/m
143
+ app_delegate_swift = File.read app_delegate_swift_path
144
+
145
+ if app_delegate_swift =~ /application:.*continue userActivity:.*restorationHandler:/
146
+ patch = load_patch :continue_user_activity_swift
160
147
  else
161
- # Add the application:continueUserActivity:restorationHandler method if it does not exist
162
- patch_name += "new_swift"
163
- patch = load_patch patch_name
164
- patch.regexp = /\n\s*\}[^{}]*\Z/m
148
+ patch = load_patch :continue_user_activity_new_swift
165
149
  end
166
150
  patch.apply app_delegate_swift_path
167
151
  end
168
152
 
169
153
  def patch_open_url_method_objc(app_delegate_objc_path)
170
154
  app_delegate_objc = File.read app_delegate_objc_path
171
- patch_name = "open_url_"
155
+
172
156
  if app_delegate_objc =~ /application:.*openURL:.*options/
173
157
  # Has application:openURL:options:
174
- patch_name += "objc"
175
- patch = load_patch patch_name
176
- patch.regexp = /application:.*openURL:.*options:.*?\{.*?\n/m
158
+ patch = load_patch :open_url_objc
177
159
  elsif app_delegate_objc =~ /application:.*openURL:.*sourceApplication/
178
160
  # Has application:openURL:sourceApplication:annotation:
179
- patch_name += "source_application_objc"
180
- patch = load_patch patch_name
181
- patch.regexp = /application:.*openURL:.*sourceApplication:.*?\{.*?\n/m
161
+ patch = load_patch :open_url_source_annotation_objc
162
+ # TODO: This method is deprecated.
182
163
  else
183
164
  # Has neither
184
- patch_name += "new_objc"
185
- patch = load_patch patch_name
186
- patch.regexp = /\n\s*@end[^@]*\Z/m
165
+ patch = load_patch :open_url_new_objc
187
166
  end
188
167
  patch.apply app_delegate_objc_path
189
168
  end
190
169
 
191
170
  def patch_continue_user_activity_method_objc(app_delegate_objc_path)
192
- app_delegate = File.read app_delegate_objc_path
193
- patch_name = "continue_user_activity_"
194
- if app_delegate =~ /application:.*continueUserActivity:.*restorationHandler:/
195
- patch_name += "objc"
196
- patch = load_patch patch_name
197
- patch.regexp = /application:.*continueUserActivity:.*restorationHandler:.*?\{.*?\n/m
171
+ app_delegate_swift = File.read app_delegate_objc_path
172
+
173
+ if app_delegate_swift =~ /application:.*continueUserActivity:.*restorationHandler:/
174
+ patch = load_patch :continue_user_activity_objc
198
175
  else
199
- # Add the application:continueUserActivity:restorationHandler method if it does not exist
200
- patch_name += "new_objc"
201
- patch = load_patch patch_name
202
- patch.regexp = /\n\s*@end[^@]*\Z/m
176
+ patch = load_patch :continue_user_activity_new_objc
203
177
  end
204
178
  patch.apply app_delegate_objc_path
205
179
  end
206
180
 
207
181
  def patch_podfile(podfile_path)
208
- podfile = File.read podfile_path
182
+ target_definition = config.podfile.target_definitions[config.target.name]
183
+ raise "Target #{config.target.name} not found in Podfile" unless target_definition
209
184
 
210
- # Podfile already contains the Branch pod
211
- # TODO: Allow for adding to multiple targets in the Podfile
212
- return false if podfile =~ /pod\s+('Branch'|"Branch")/
185
+ # Podfile already contains the Branch pod, possibly just a subspec
186
+ return false if target_definition.dependencies.any? { |d| d.name =~ %r{^(Branch|Branch-SDK)(/.*)?$} }
213
187
 
214
188
  say "Adding pod \"Branch\" to #{podfile_path}"
215
189
 
190
+ # It may not be clear from the Pod::Podfile whether the target has a do block.
191
+ # It doesn't seem to be possible to update the Podfile object and write it out.
192
+ # So we patch.
193
+ podfile = File.read config.podfile_path
194
+
216
195
  if podfile =~ /target\s+(["'])#{config.target.name}\1\s+do.*?\n/m
217
196
  # if there is a target block for this target:
218
197
  patch = PatternPatch::Patch.new(
@@ -1,3 +1,3 @@
1
1
  module BranchIOCLI
2
- VERSION = "0.9.2"
2
+ VERSION = "0.9.3"
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.9.2
4
+ version: 0.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Branch
@@ -59,14 +59,14 @@ dependencies:
59
59
  requirements:
60
60
  - - ">="
61
61
  - !ruby/object:Gem::Version
62
- version: 0.4.0
62
+ version: 0.5.1
63
63
  type: :runtime
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
67
  - - ">="
68
68
  - !ruby/object:Gem::Version
69
- version: 0.4.0
69
+ version: 0.5.1
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: plist
72
72
  requirement: !ruby/object:Gem::Requirement
@@ -267,6 +267,8 @@ files:
267
267
  - lib/assets/patches/continue_user_activity_new_swift.yml
268
268
  - lib/assets/patches/continue_user_activity_objc.yml
269
269
  - lib/assets/patches/continue_user_activity_swift.yml
270
+ - lib/assets/patches/did_finish_launching_new_objc.yml
271
+ - lib/assets/patches/did_finish_launching_new_swift.yml
270
272
  - lib/assets/patches/did_finish_launching_objc.yml
271
273
  - lib/assets/patches/did_finish_launching_swift.yml
272
274
  - lib/assets/patches/objc_import.yml