pod-builder 2.0.0.beta.19 ā 2.0.0.beta.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +2 -2
- data/README.md +13 -13
- data/exe/pod_builder +27 -16
- data/lib/pod_builder/command/build.rb +28 -159
- data/lib/pod_builder/command/build_all.rb +2 -2
- data/lib/pod_builder/command/clean.rb +34 -53
- data/lib/pod_builder/command/clear_lldbinit.rb +6 -2
- data/lib/pod_builder/command/deintegrate.rb +27 -6
- data/lib/pod_builder/command/generate_lfs.rb +1 -1
- data/lib/pod_builder/command/generate_podspec.rb +3 -2
- data/lib/pod_builder/command/info.rb +1 -1
- data/lib/pod_builder/command/init.rb +39 -14
- data/lib/pod_builder/command/install_sources.rb +20 -13
- data/lib/pod_builder/command/none.rb +2 -2
- data/lib/pod_builder/command/restore_all.rb +4 -4
- data/lib/pod_builder/command/switch.rb +56 -14
- data/lib/pod_builder/command/sync_podfile.rb +3 -2
- data/lib/pod_builder/command/update.rb +5 -6
- data/lib/pod_builder/command/update_lldbinit.rb +10 -8
- data/lib/pod_builder/configuration.rb +27 -7
- data/lib/pod_builder/core.rb +52 -16
- data/lib/pod_builder/info.rb +11 -11
- data/lib/pod_builder/install.rb +200 -186
- data/lib/pod_builder/licenses.rb +4 -4
- data/lib/pod_builder/podfile.rb +245 -86
- data/lib/pod_builder/podfile/post_actions.rb +9 -14
- data/lib/pod_builder/podfile_cp.rb +93 -0
- data/lib/pod_builder/podfile_item.rb +41 -20
- data/lib/pod_builder/podspec.rb +33 -16
- data/lib/pod_builder/rome/post_install.rb +285 -130
- data/lib/pod_builder/rome/pre_install.rb +1 -1
- data/lib/pod_builder/templates/build_podfile.template +3 -3
- data/lib/pod_builder/version.rb +1 -1
- data/pod-builder.gemspec +2 -2
- metadata +4 -25
- data/Example/Frameworks/.gitignore +0 -6
- data/Example/Frameworks/.pod_builder/pod_builder +0 -0
- data/Example/Frameworks/PodBuilder.json +0 -38
- data/Example/Frameworks/Podfile +0 -23
- data/Example/Frameworks/Podfile.restore +0 -40
- data/Example/PodBuilderExample.xcodeproj/project.pbxproj +0 -411
- data/Example/PodBuilderExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
- data/Example/PodBuilderExample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- data/Example/PodBuilderExample.xcodeproj/project.xcworkspace/xcuserdata/tomas.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- data/Example/PodBuilderExample.xcworkspace/contents.xcworkspacedata +0 -10
- data/Example/PodBuilderExample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- data/Example/PodBuilderExample/AppDelegate.swift +0 -51
- data/Example/PodBuilderExample/Assets.xcassets/AppIcon.appiconset/Contents.json +0 -98
- data/Example/PodBuilderExample/Assets.xcassets/Contents.json +0 -6
- data/Example/PodBuilderExample/Base.lproj/LaunchScreen.storyboard +0 -25
- data/Example/PodBuilderExample/Base.lproj/Main.storyboard +0 -24
- data/Example/PodBuilderExample/Info.plist +0 -45
- data/Example/PodBuilderExample/ViewController.swift +0 -25
- data/Example/Podfile +0 -51
- data/Example/Podfile.lock +0 -435
- data/Example/Pods-acknowledgements.md +0 -210
- data/Example/Pods-acknowledgements.plist +0 -206
data/lib/pod_builder/licenses.rb
CHANGED
@@ -12,19 +12,19 @@
|
|
12
12
|
|
13
13
|
if current_licenses.count > 0
|
14
14
|
licenses_header = current_licenses.shift
|
15
|
-
raise "
|
15
|
+
raise "\n\nUnexpected license found in header".red if licenses_header.has_key?("License")
|
16
16
|
end
|
17
17
|
if current_licenses.count > 0
|
18
18
|
license_footer = current_licenses.pop
|
19
|
-
raise "
|
19
|
+
raise "\n\nUnexpected license found in footer".red if license_footer.has_key?("License")
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
23
|
if licenses.count > 0
|
24
24
|
licenses_header = licenses.shift
|
25
|
-
raise "
|
25
|
+
raise "\n\nUnexpected license found in header".red if licenses_header.has_key?("License")
|
26
26
|
license_footer = licenses.pop
|
27
|
-
raise "
|
27
|
+
raise "\n\nUnexpected license found in footer".red if license_footer.has_key?("License")
|
28
28
|
|
29
29
|
lincenses_titles = licenses.map { |x| x["Title"] }
|
30
30
|
current_licenses.select! { |x| !lincenses_titles.include?(x["Title"]) }
|
data/lib/pod_builder/podfile.rb
CHANGED
@@ -1,13 +1,14 @@
|
|
1
|
+
require 'json'
|
1
2
|
module PodBuilder
|
2
3
|
class Podfile
|
3
4
|
PODBUILDER_LOCK_ACTION = ["raise \"\\nšØ Do not launch 'pod install' manually, use `pod_builder` instead!\\n\" if !File.exist?('pod_builder.lock')"].freeze
|
4
|
-
POST_INSTALL_ACTIONS = ["require 'pod_builder/podfile/post_actions'", "PodBuilder::Podfile::
|
5
|
+
POST_INSTALL_ACTIONS = ["require 'pod_builder/podfile/post_actions'", "PodBuilder::Podfile::pod_builder_post_process"].freeze
|
5
6
|
|
6
7
|
PRE_INSTALL_ACTIONS = ["Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_duplicate_framework_and_library_names) {}"].freeze
|
7
8
|
private_constant :PRE_INSTALL_ACTIONS
|
8
9
|
|
9
10
|
def self.from_podfile_items(items, analyzer, build_configuration)
|
10
|
-
raise "
|
11
|
+
raise "\n\nno items".red unless items.count > 0
|
11
12
|
|
12
13
|
sources = analyzer.sources
|
13
14
|
|
@@ -15,6 +16,12 @@ module PodBuilder
|
|
15
16
|
podfile = File.read("#{cwd}/templates/build_podfile.template")
|
16
17
|
|
17
18
|
platform = analyzer.instance_variable_get("@result").targets.first.platform
|
19
|
+
|
20
|
+
install_using_frameworks = install_using_frameworks(analyzer)
|
21
|
+
|
22
|
+
podfile.sub!("%%%use_frameworks%%%", install_using_frameworks ? "use_frameworks!" : "")
|
23
|
+
podfile.sub!("%%%uses_frameworks%%%", install_using_frameworks ? "true" : "false")
|
24
|
+
|
18
25
|
podfile.sub!("%%%platform_name%%%", platform.name.to_s)
|
19
26
|
podfile.sub!("%%%deployment_version%%%", platform.deployment_target.version)
|
20
27
|
|
@@ -40,7 +47,7 @@ module PodBuilder
|
|
40
47
|
|
41
48
|
# Don't store .pcm info in binary, see https://forums.swift.org/t/swift-behavior-of-gmodules-and-dsyms/23211/3
|
42
49
|
build_settings['CLANG_ENABLE_MODULE_DEBUGGING'] = 'NO'
|
43
|
-
build_settings['OTHER_SWIFT_FLAGS'] = "-Xfrontend -no-clang-module-breadcrumbs"
|
50
|
+
build_settings['OTHER_SWIFT_FLAGS'] = "$(inherited) -Xfrontend -no-clang-module-breadcrumbs"
|
44
51
|
|
45
52
|
# Improve compile speed
|
46
53
|
build_settings['COMPILER_INDEX_STORE_ENABLE'] = 'NO'
|
@@ -49,7 +56,7 @@ module PodBuilder
|
|
49
56
|
|
50
57
|
if Configuration.build_system == "Legacy"
|
51
58
|
build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = "NO"
|
52
|
-
raise "\n\nCan't enable library evolution support with legacy build system!" if Configuration.library_evolution_support
|
59
|
+
raise "\n\nCan't enable library evolution support with legacy build system!".red if Configuration.library_evolution_support
|
53
60
|
elsif Configuration.library_evolution_support
|
54
61
|
build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = "YES"
|
55
62
|
end
|
@@ -151,7 +158,11 @@ module PodBuilder
|
|
151
158
|
File.write(podfile_restore_path, podfile_content.join("\n"))
|
152
159
|
end
|
153
160
|
|
154
|
-
def self.write_prebuilt(all_buildable_items, analyzer)
|
161
|
+
def self.write_prebuilt(all_buildable_items, analyzer)
|
162
|
+
if Configuration.react_native_project
|
163
|
+
return write_prebuilt_react_native(all_buildable_items, analyzer)
|
164
|
+
end
|
165
|
+
|
155
166
|
puts "Updating Application Podfile".yellow
|
156
167
|
|
157
168
|
explicit_deps = analyzer.explicit_pods()
|
@@ -171,45 +182,33 @@ module PodBuilder
|
|
171
182
|
next
|
172
183
|
end
|
173
184
|
|
174
|
-
if pod_name = pod_definition_in(line, true)
|
185
|
+
if pod_name = pod_definition_in(line, true)
|
175
186
|
if podfile_item = all_buildable_items.detect { |x| x.name == pod_name }
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
item
|
195
|
-
else
|
196
|
-
item = all_buildable_items.detect { |t| x == t.root_name }
|
197
|
-
end
|
198
|
-
}.compact
|
199
|
-
|
200
|
-
non_explicit_dependencies.each do |dep|
|
201
|
-
dep_item = all_buildable_items.detect { |x| x.name == dep.name }
|
202
|
-
|
203
|
-
if Podspec.include?(dep_item.root_name)
|
204
|
-
pod_name = dep_item.prebuilt_entry(false)
|
205
|
-
pod_name.gsub!(dep.name, dep.root_name)
|
206
|
-
prebuilt_lines.push("#{line.detect_indentation}#{pod_name}#{marker}\n")
|
207
|
-
end
|
208
|
-
|
209
|
-
explicit_deps.push(dep)
|
210
|
-
end
|
187
|
+
marker = podfile_item.prebuilt_marker()
|
188
|
+
|
189
|
+
non_explicit_dependencies = podfile_item.recursive_dependencies(all_buildable_items) - explicit_deps
|
190
|
+
non_explicit_dependencies_root_names = non_explicit_dependencies.map(&:root_name).uniq.filter { |t| t != podfile_item.root_name }
|
191
|
+
non_explicit_dependencies = non_explicit_dependencies_root_names.map { |x|
|
192
|
+
if item = all_buildable_items.detect { |t| x == t.name }
|
193
|
+
item
|
194
|
+
else
|
195
|
+
item = all_buildable_items.detect { |t| x == t.root_name }
|
196
|
+
end
|
197
|
+
}.compact
|
198
|
+
|
199
|
+
non_explicit_dependencies.each do |dep|
|
200
|
+
dep_item = all_buildable_items.detect { |x| x.name == dep.name }
|
201
|
+
|
202
|
+
if File.exist?(dep_item.prebuilt_podspec_path) && !dep_item.is_prebuilt
|
203
|
+
pod_name = dep_item.prebuilt_entry(false, false)
|
204
|
+
prebuilt_lines.push("#{line.detect_indentation}#{pod_name}#{marker}\n")
|
211
205
|
end
|
212
206
|
|
207
|
+
explicit_deps.push(dep)
|
208
|
+
end
|
209
|
+
|
210
|
+
if File.exist?(podfile_item.prebuilt_podspec_path) && !podfile_item.is_prebuilt
|
211
|
+
prebuilt_lines.push("#{line.detect_indentation}#{podfile_item.prebuilt_entry}\n")
|
213
212
|
next
|
214
213
|
end
|
215
214
|
end
|
@@ -218,13 +217,37 @@ module PodBuilder
|
|
218
217
|
prebuilt_lines.push(line)
|
219
218
|
end
|
220
219
|
|
220
|
+
podfile_content = prebuilt_lines.join
|
221
|
+
|
222
|
+
podfile_content = Podfile.update_path_entries(podfile_content, Podfile.method(:podfile_path_transform))
|
223
|
+
podfile_content = Podfile.update_project_entries(podfile_content, Podfile.method(:podfile_path_transform))
|
224
|
+
podfile_content = Podfile.update_require_entries(podfile_content, Podfile.method(:podfile_path_transform))
|
225
|
+
|
226
|
+
podfile_content = add_pre_install_actions(podfile_content)
|
227
|
+
podfile_content = add_post_install_checks(podfile_content)
|
228
|
+
|
221
229
|
project_podfile_path = PodBuilder::project_path("Podfile")
|
222
|
-
File.write(project_podfile_path,
|
223
|
-
|
224
|
-
|
230
|
+
File.write(project_podfile_path, podfile_content)
|
231
|
+
end
|
232
|
+
|
233
|
+
def self.write_prebuilt_react_native(all_buildable_items, analyzer)
|
234
|
+
puts "Updating Application Podfile".yellow
|
225
235
|
|
226
|
-
|
227
|
-
|
236
|
+
podbuilder_podfile_path = PodBuilder::basepath("Podfile")
|
237
|
+
rel_path = Pathname.new(podbuilder_podfile_path).relative_path_from(Pathname.new(PodBuilder::project_path)).to_s
|
238
|
+
|
239
|
+
podfile_content = ["# Autogenerated by PodBuilder (https://github.com/Subito-it/PodBuilder)\n", "# Any change to this file should be done on #{rel_path}\n", "\n"].join
|
240
|
+
podfile_content += analyzer.podfile.pb_to_s(all_buildable_items)
|
241
|
+
|
242
|
+
podfile_content = Podfile.update_path_entries(podfile_content, PodfileCP.method(:podfile_path_transform))
|
243
|
+
podfile_content = Podfile.update_project_entries(podfile_content, Podfile.method(:podfile_path_transform))
|
244
|
+
podfile_content = Podfile.update_require_entries(podfile_content, Podfile.method(:podfile_path_transform))
|
245
|
+
|
246
|
+
podfile_content = add_pre_install_actions(podfile_content)
|
247
|
+
podfile_content = add_post_install_checks(podfile_content)
|
248
|
+
|
249
|
+
project_podfile_path = PodBuilder::project_path("Podfile")
|
250
|
+
File.write(project_podfile_path, podfile_content)
|
228
251
|
end
|
229
252
|
|
230
253
|
def self.install
|
@@ -241,10 +264,6 @@ module PodBuilder
|
|
241
264
|
return stripped_line.gsub("\"", "'").gsub(" ", "").gsub("\t", "").gsub("\n", "")
|
242
265
|
end
|
243
266
|
|
244
|
-
def self.add_install_block(podfile_path)
|
245
|
-
add(PODBUILDER_LOCK_ACTION, "pre_install", podfile_path)
|
246
|
-
end
|
247
|
-
|
248
267
|
def self.pod_definition_in(line, include_commented)
|
249
268
|
stripped_line = strip_line(line)
|
250
269
|
matches = stripped_line.match(/(^pod')(.*?)(')/)
|
@@ -330,7 +349,7 @@ module PodBuilder
|
|
330
349
|
|
331
350
|
if stripped_line.match(/(pod')(.*?)(')/) != nil
|
332
351
|
starting_def_found = stripped_line.start_with?("def") && (line.match("\s*def\s") != nil)
|
333
|
-
raise "
|
352
|
+
raise "\n\nUnsupported single line def/pod. `def` and `pod` shouldn't be on the same line, please modify the following line:\n#{line}".red if starting_def_found
|
334
353
|
end
|
335
354
|
end
|
336
355
|
end
|
@@ -369,9 +388,23 @@ module PodBuilder
|
|
369
388
|
|
370
389
|
private
|
371
390
|
|
372
|
-
def self.
|
373
|
-
|
391
|
+
def self.podfile_path_transform(path)
|
392
|
+
use_absolute_paths = false
|
393
|
+
podfile_path = PodBuilder::project_path("Podfile")
|
394
|
+
original_basepath = PodBuilder::basepath
|
395
|
+
|
396
|
+
podfile_base_path = Pathname.new(File.dirname(podfile_path))
|
397
|
+
|
398
|
+
original_path = Pathname.new(File.join(original_basepath, path))
|
399
|
+
replace_path = original_path.relative_path_from(podfile_base_path)
|
400
|
+
if use_absolute_paths
|
401
|
+
replace_path = replace_path.expand_path(podfile_base_path)
|
402
|
+
end
|
374
403
|
|
404
|
+
return replace_path
|
405
|
+
end
|
406
|
+
|
407
|
+
def self.indentation_from_string(content)
|
375
408
|
lines = content.split("\n").select { |x| !x.empty? }
|
376
409
|
|
377
410
|
if lines.count > 2
|
@@ -392,13 +425,13 @@ module PodBuilder
|
|
392
425
|
def self.project_swift_version(analyzer)
|
393
426
|
swift_versions = analyzer.instance_variable_get("@result").targets.map { |x| x.target_definition.swift_version }.compact.uniq
|
394
427
|
|
395
|
-
raise "
|
428
|
+
raise "\n\nFound different Swift versions in targets. Expecting one, got `#{swift_versions}`".red if swift_versions.count > 1
|
396
429
|
|
397
430
|
return swift_versions.first || PodBuilder::system_swift_version
|
398
431
|
end
|
399
432
|
|
400
433
|
def self.podfile_items_at(podfile_path, include_prebuilt = false)
|
401
|
-
raise "
|
434
|
+
raise "\n\nExpecting basepath folder!".red if !File.exist?(PodBuilder::basepath("Podfile"))
|
402
435
|
|
403
436
|
if File.basename(podfile_path) != "Podfile"
|
404
437
|
File.rename(PodBuilder::basepath("Podfile"), PodBuilder::basepath("Podfile.tmp"))
|
@@ -427,18 +460,20 @@ module PodBuilder
|
|
427
460
|
return buildable_items
|
428
461
|
end
|
429
462
|
|
430
|
-
def self.
|
431
|
-
add(
|
463
|
+
def self.add_install_block(podfile_content)
|
464
|
+
return add(PODBUILDER_LOCK_ACTION, "pre_install", podfile_content)
|
432
465
|
end
|
433
466
|
|
434
|
-
def self.
|
435
|
-
add(
|
467
|
+
def self.add_pre_install_actions(podfile_content)
|
468
|
+
return add(PRE_INSTALL_ACTIONS + [" "], "pre_install", podfile_content)
|
436
469
|
end
|
437
470
|
|
438
|
-
def self.
|
439
|
-
|
471
|
+
def self.add_post_install_checks(podfile_content)
|
472
|
+
return add(POST_INSTALL_ACTIONS + [" "], "post_install", podfile_content)
|
473
|
+
end
|
440
474
|
|
441
|
-
|
475
|
+
def self.add(entries, marker, podfile_content)
|
476
|
+
file_indentation = indentation_from_string(podfile_content)
|
442
477
|
|
443
478
|
entries = entries.map { |x| "#{file_indentation}#{x}\n"}
|
444
479
|
|
@@ -455,28 +490,28 @@ module PodBuilder
|
|
455
490
|
end
|
456
491
|
|
457
492
|
if !marker_found
|
493
|
+
if podfile_lines.last.strip.length > 0
|
494
|
+
podfile_lines.push("\n")
|
495
|
+
end
|
458
496
|
podfile_lines.push("\n#{marker} do |installer|\n")
|
459
497
|
podfile_lines.push(entries)
|
460
498
|
podfile_lines.push("end\n")
|
461
499
|
end
|
462
500
|
|
463
|
-
|
501
|
+
return podfile_lines.join
|
464
502
|
end
|
465
503
|
|
466
|
-
def self.
|
467
|
-
|
468
|
-
|
469
|
-
base_path = Pathname.new(File.dirname(podfile_path))
|
470
|
-
regex = "(\s*pod\s*['|\"])(.*?)(['|\"])(.*?)(:path\s*=>\s*['|\"])(.*?)(['|\"])"
|
504
|
+
def self.update_path_entries(podfile_content, path_transform)
|
505
|
+
regex = "(\s*pod\s*['|\"])(.*?)(['|\"])(.*?):(path|podspec)(\s*=>\s*['|\"])(.*?)(['|\"])"
|
471
506
|
|
472
507
|
podfile_lines = []
|
473
508
|
podfile_content.each_line do |line|
|
474
509
|
stripped_line = strip_line(line)
|
475
510
|
matches = line.match(/#{regex}/)
|
476
511
|
|
477
|
-
if matches&.size ==
|
512
|
+
if matches&.size == 9 && !stripped_line.start_with?("#")
|
478
513
|
pod_name = matches[2]
|
479
|
-
path = matches[
|
514
|
+
path = matches[7]
|
480
515
|
|
481
516
|
is_absolute = ["~", "/"].include?(path[0])
|
482
517
|
unless !PodBuilder::prebuiltpath.end_with?(path) && !is_absolute
|
@@ -484,26 +519,19 @@ module PodBuilder
|
|
484
519
|
next
|
485
520
|
end
|
486
521
|
|
487
|
-
|
488
|
-
replace_path = original_path.relative_path_from(base_path)
|
489
|
-
if use_absolute_paths
|
490
|
-
replace_path = replace_path.expand_path(base_path)
|
491
|
-
end
|
522
|
+
replace_path = path_transform.call(path)
|
492
523
|
|
493
|
-
updated_path_line = line.gsub(/#{regex}/, '\1\2\3\4\
|
524
|
+
updated_path_line = line.gsub(/#{regex}/, '\1\2\3\4:\5\6' + replace_path.to_s + '\8\9')
|
494
525
|
podfile_lines.push(updated_path_line)
|
495
526
|
else
|
496
527
|
podfile_lines.push(line)
|
497
528
|
end
|
498
529
|
end
|
499
530
|
|
500
|
-
|
531
|
+
return podfile_lines.join
|
501
532
|
end
|
502
533
|
|
503
|
-
def self.update_project_entries(
|
504
|
-
podfile_content = File.read(podfile_path)
|
505
|
-
|
506
|
-
base_path = Pathname.new(File.dirname(podfile_path))
|
534
|
+
def self.update_project_entries(podfile_content, path_transform)
|
507
535
|
regex = "(\s*project\s*['|\"])(.*?)(['|\"])"
|
508
536
|
|
509
537
|
podfile_lines = []
|
@@ -520,11 +548,36 @@ module PodBuilder
|
|
520
548
|
next
|
521
549
|
end
|
522
550
|
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
551
|
+
replace_path = path_transform.call(path)
|
552
|
+
|
553
|
+
updated_path_line = line.gsub(/#{regex}/, '\1' + replace_path.to_s + '\3\4')
|
554
|
+
podfile_lines.push(updated_path_line)
|
555
|
+
else
|
556
|
+
podfile_lines.push(line)
|
557
|
+
end
|
558
|
+
end
|
559
|
+
|
560
|
+
return podfile_lines.join
|
561
|
+
end
|
562
|
+
|
563
|
+
def self.update_require_entries(podfile_content, path_transform)
|
564
|
+
regex = "(\s*require_relative\s*['|\"])(.*?)(['|\"])"
|
565
|
+
|
566
|
+
podfile_lines = []
|
567
|
+
podfile_content.each_line do |line|
|
568
|
+
stripped_line = strip_line(line)
|
569
|
+
matches = line.match(/#{regex}/)
|
570
|
+
|
571
|
+
if matches&.size == 4 && !stripped_line.start_with?("#")
|
572
|
+
path = matches[2]
|
573
|
+
|
574
|
+
is_absolute = ["~", "/"].include?(path[0])
|
575
|
+
unless !is_absolute
|
576
|
+
podfile_lines.push(line)
|
577
|
+
next
|
527
578
|
end
|
579
|
+
|
580
|
+
replace_path = path_transform.call(path)
|
528
581
|
|
529
582
|
updated_path_line = line.gsub(/#{regex}/, '\1' + replace_path.to_s + '\3\4')
|
530
583
|
podfile_lines.push(updated_path_line)
|
@@ -533,7 +586,113 @@ module PodBuilder
|
|
533
586
|
end
|
534
587
|
end
|
535
588
|
|
536
|
-
|
589
|
+
return podfile_lines.join
|
590
|
+
end
|
591
|
+
|
592
|
+
def self.prepare_for_react_native_write_pb_configuration(podfile_content)
|
593
|
+
base = File.expand_path(File.join(PodBuilder::project_path, ".."))
|
594
|
+
bin_js = Dir.glob("#{base}/node_modules/@react-native-community/cli/build/bin.js")
|
595
|
+
|
596
|
+
raise "\n\nReact native cli bin_js not found!".red unless bin_js.count == 1
|
597
|
+
bin_js = bin_js.first
|
598
|
+
|
599
|
+
config_dest_path = PodBuilder::basepath("rn_config.json")
|
600
|
+
|
601
|
+
raise "\n\nFailed generating react native configuration file".red unless system("node '#{bin_js}' config > #{config_dest_path}")
|
602
|
+
|
603
|
+
content = File.read(config_dest_path)
|
604
|
+
|
605
|
+
content.gsub!(PodBuilder::project_path, "..")
|
606
|
+
content.gsub!(File.expand_path(PodBuilder::project_path("..")), "../..")
|
607
|
+
|
608
|
+
json = JSON.parse(content)
|
609
|
+
begin
|
610
|
+
json["project"]["ios"]["sourceDir"] = "./"
|
611
|
+
json["project"]["ios"]["podfile"] = "./"
|
612
|
+
rescue => exception
|
613
|
+
raise "\n\nFailed updating react native configuration json".red
|
614
|
+
end
|
615
|
+
|
616
|
+
File.write(config_dest_path, JSON.pretty_generate(json))
|
617
|
+
|
618
|
+
return "rn_config = JSON.load(File.read(\"rn_config.json\")) # pb added\n\n" + podfile_content
|
619
|
+
end
|
620
|
+
|
621
|
+
def self.prepare_for_react_native_rn_pods_file(podfile_content)
|
622
|
+
lines = []
|
623
|
+
podfile_content.each_line do |line|
|
624
|
+
if line.include?("use_react_native!")
|
625
|
+
matches = line.match(/(\s*)/)
|
626
|
+
unless matches&.size == 2
|
627
|
+
return podfile_content
|
628
|
+
end
|
629
|
+
|
630
|
+
indentation = matches[1]
|
631
|
+
lines.push("#{indentation}use_react_native!(:path => rn_config[\"reactNativePath\"]) # pb added\n")
|
632
|
+
lines.push("#{indentation}# #{line.strip} # pb removed\n")
|
633
|
+
else
|
634
|
+
lines.push(line)
|
635
|
+
end
|
636
|
+
end
|
637
|
+
|
638
|
+
return lines.join
|
639
|
+
end
|
640
|
+
|
641
|
+
def self.prepare_for_react_native_native_modules_file(podfile_content)
|
642
|
+
lines = []
|
643
|
+
podfile_content.each_line do |line|
|
644
|
+
if line.include?("use_native_modules!")
|
645
|
+
matches = line.match(/(\s*)/)
|
646
|
+
unless matches&.size == 2
|
647
|
+
return podfile_content
|
648
|
+
end
|
649
|
+
|
650
|
+
indentation = matches[1]
|
651
|
+
lines.push("#{indentation}use_native_modules!(rn_config) # pb added\n")
|
652
|
+
lines.push("#{indentation}# #{line.strip} # pb removed\n")
|
653
|
+
else
|
654
|
+
lines.push(line)
|
655
|
+
end
|
656
|
+
end
|
657
|
+
|
658
|
+
return lines.join
|
659
|
+
end
|
660
|
+
|
661
|
+
def self.prepare_for_react_native(podfile_content)
|
662
|
+
original_podfile_content = podfile_content.dup
|
663
|
+
|
664
|
+
podfile_content = prepare_for_react_native_write_pb_configuration(podfile_content)
|
665
|
+
content = prepare_for_react_native_rn_pods_file(podfile_content)
|
666
|
+
if content == podfile_content
|
667
|
+
return original_podfile_content
|
668
|
+
end
|
669
|
+
podfile_content = content
|
670
|
+
content = prepare_for_react_native_native_modules_file(podfile_content)
|
671
|
+
if content == podfile_content
|
672
|
+
return original_podfile_content
|
673
|
+
end
|
674
|
+
podfile_content = content
|
675
|
+
|
676
|
+
Configuration.build_using_repo_paths = true
|
677
|
+
Configuration.react_native_project = true
|
678
|
+
|
679
|
+
return podfile_content
|
680
|
+
end
|
681
|
+
|
682
|
+
def self.install_using_frameworks(analyzer)
|
683
|
+
target_settings = analyzer.podfile.target_definition_list.map(&:uses_frameworks?).uniq
|
684
|
+
if target_settings.count == 1
|
685
|
+
if target_settings.first == false && ENV['DEBUGGING'].nil?
|
686
|
+
raise "\n\nOnly framework packaging currently supported. Please add 'use_frameworks!' at Podfile root level (not nested in targets)".red
|
687
|
+
end
|
688
|
+
return target_settings.first
|
689
|
+
elsif target_settings.count > 1
|
690
|
+
raise "\n\n'use_frameworks!' should be declared only once at Podfile root level (not nested in targets)".red
|
691
|
+
else
|
692
|
+
raise "\n\nFailed detecting use_frameworks!"
|
693
|
+
end
|
694
|
+
|
695
|
+
return true
|
537
696
|
end
|
538
697
|
end
|
539
698
|
end
|