pod-builder 5.1.1 → 5.1.2
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/Gemfile +1 -1
- data/exe/pod_builder +105 -77
- data/lib/pod_builder/command/build.rb +41 -41
- data/lib/pod_builder/command/build_swiftmodules.rb +123 -0
- data/lib/pod_builder/command/init.rb +16 -16
- data/lib/pod_builder/command.rb +16 -15
- data/lib/pod_builder/configuration.rb +42 -34
- data/lib/pod_builder/install.rb +92 -90
- data/lib/pod_builder/podfile.rb +66 -59
- data/lib/pod_builder/podfile_item.rb +52 -52
- data/lib/pod_builder/rome/post_install.rb +151 -119
- data/lib/pod_builder/templates/build_podfile.template +1 -1
- data/lib/pod_builder/version.rb +1 -1
- metadata +3 -2
data/lib/pod_builder/podfile.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
-
require
|
1
|
+
require "json"
|
2
|
+
|
2
3
|
module PodBuilder
|
3
4
|
class Podfile
|
4
|
-
PODBUILDER_LOCK_ACTION = ["raise \"\\n🚨 Do not launch 'pod install' manually, use `pod_builder` instead!\\n\" if !File.exist?('pod_builder.lock')"].freeze
|
5
|
-
|
5
|
+
PODBUILDER_LOCK_ACTION = ["raise \"\\n🚨 Do not launch 'pod install' manually, use `pod_builder` instead!\\n\" if !File.exist?('pod_builder.lock')"].freeze
|
6
|
+
|
6
7
|
def self.from_podfile_items(items, analyzer, build_configuration, install_using_frameworks, build_catalyst, build_xcframeworks)
|
7
8
|
raise "\n\nno items\n".red unless items.count > 0
|
8
9
|
|
@@ -19,35 +20,36 @@ module PodBuilder
|
|
19
20
|
end
|
20
21
|
|
21
22
|
sources = analyzer.sources
|
22
|
-
|
23
|
+
|
23
24
|
cwd = File.dirname(File.expand_path(__FILE__))
|
24
25
|
podfile = File.read("#{cwd}/templates/build_podfile.template")
|
25
26
|
|
26
27
|
platform = analyzer.instance_variable_get("@result").targets.first.platform
|
27
28
|
|
28
|
-
podfile.sub!("%%%use_frameworks%%%", install_using_frameworks ? "use_frameworks!" : "use_modular_headers!")
|
29
|
-
podfile.sub!("%%%uses_frameworks%%%", install_using_frameworks ? "true" : "false")
|
30
|
-
podfile.sub!("%%%build_xcframeworks%%%", build_xcframeworks ? "true" : "false")
|
31
|
-
podfile.sub!("%%%build_catalyst%%%", build_catalyst ? "true" : "false")
|
32
|
-
|
29
|
+
podfile.sub!("%%%use_frameworks%%%", install_using_frameworks ? "use_frameworks!" : "use_modular_headers!")
|
30
|
+
podfile.sub!("%%%uses_frameworks%%%", install_using_frameworks ? "true" : "false")
|
31
|
+
podfile.sub!("%%%build_xcframeworks%%%", build_xcframeworks ? "true" : "false")
|
32
|
+
podfile.sub!("%%%build_catalyst%%%", build_catalyst ? "true" : "false")
|
33
|
+
|
33
34
|
podfile.sub!("%%%platform_name%%%", platform.name.to_s)
|
34
35
|
podfile.sub!("%%%deployment_version%%%", platform.deployment_target.version)
|
35
36
|
|
36
37
|
podfile.sub!("%%%sources%%%", sources.map { |x| "source '#{x.url}'" }.join("\n"))
|
37
38
|
|
38
39
|
podfile.sub!("%%%build_configuration%%%", build_configuration.capitalize)
|
40
|
+
podfile.sub!("%%%keep_swiftmodules%%%", Configuration.keep_swiftmodules ? "true" : "false")
|
39
41
|
|
40
42
|
podfile.sub!("%%%development_team%%%", development_team)
|
41
43
|
|
42
44
|
podfile_build_settings = ""
|
43
|
-
|
45
|
+
|
44
46
|
pod_dependencies = {}
|
45
|
-
|
47
|
+
|
46
48
|
items.each do |item|
|
47
49
|
build_settings = Configuration.build_settings.dup
|
48
50
|
|
49
51
|
item_build_settings = Configuration.build_settings_overrides[item.name].dup || {}
|
50
|
-
|
52
|
+
|
51
53
|
# These settings need to be set as is to properly build frameworks
|
52
54
|
build_settings["SWIFT_COMPILATION_MODE"] = "wholemodule"
|
53
55
|
build_settings["ONLY_ACTIVE_ARCH"] = "NO"
|
@@ -94,7 +96,7 @@ module PodBuilder
|
|
94
96
|
end
|
95
97
|
|
96
98
|
# All the below settings should be merged with global (Configuration.build_settings) or per pod build_settings (Configuration.build_settings_overrides)
|
97
|
-
build_settings["OTHER_SWIFT_FLAGS"] = build_settings.fetch("OTHER_SWIFT_FLAGS", "") + other_swift_flags_override
|
99
|
+
build_settings["OTHER_SWIFT_FLAGS"] = build_settings.fetch("OTHER_SWIFT_FLAGS", "") + other_swift_flags_override
|
98
100
|
|
99
101
|
podfile_build_settings += "set_build_settings(\"#{item.root_name}\", #{build_settings.to_s}, installer)\n "
|
100
102
|
|
@@ -106,7 +108,7 @@ module PodBuilder
|
|
106
108
|
next overridded_module_name
|
107
109
|
end
|
108
110
|
}.compact
|
109
|
-
|
111
|
+
|
110
112
|
if dependency_names.count > 0
|
111
113
|
pod_dependencies[item.root_name] = dependency_names
|
112
114
|
end
|
@@ -117,9 +119,9 @@ module PodBuilder
|
|
117
119
|
podfile.sub!("%%%build_system%%%", Configuration.build_system)
|
118
120
|
|
119
121
|
podfile.sub!("%%%pods%%%", "\"#{items.map(&:name).join('", "')}\"")
|
120
|
-
|
122
|
+
|
121
123
|
podfile.sub!("%%%pods_dependencies%%%", pod_dependencies.to_s)
|
122
|
-
|
124
|
+
|
123
125
|
podfile.sub!("%%%targets%%%", items.map(&:entry).join("\n "))
|
124
126
|
|
125
127
|
return podfile
|
@@ -129,7 +131,7 @@ module PodBuilder
|
|
129
131
|
unless Configuration.restore_enabled && (podfile_items.count + updated_pods.count) > 0
|
130
132
|
return
|
131
133
|
end
|
132
|
-
|
134
|
+
|
133
135
|
puts "Writing Restore Podfile".yellow
|
134
136
|
|
135
137
|
podfile_items = podfile_items.dup
|
@@ -140,7 +142,7 @@ module PodBuilder
|
|
140
142
|
restore_podfile_items = podfile_items_at(podfile_restore_path, include_prebuilt = true)
|
141
143
|
|
142
144
|
podfile_items.map! { |podfile_item|
|
143
|
-
if updated_pod = updated_pods.detect { |x| x.name == podfile_item.name }
|
145
|
+
if updated_pod = updated_pods.detect { |x| x.name == podfile_item.name }
|
144
146
|
updated_pod
|
145
147
|
elsif updated_pods.any? { |x| podfile_item.root_name == x.root_name } == false && # podfile_item shouldn't be among those being updated (including root specification)
|
146
148
|
restored_pod = restore_podfile_items.detect { |x| x.name == podfile_item.name }
|
@@ -150,8 +152,8 @@ module PodBuilder
|
|
150
152
|
end
|
151
153
|
}
|
152
154
|
end
|
153
|
-
|
154
|
-
result_targets = analyzer.instance_variable_get("@result").targets.map(&:name)
|
155
|
+
|
156
|
+
result_targets = analyzer.instance_variable_get("@result").targets.map(&:name)
|
155
157
|
podfile_content = ["# Autogenerated by PodBuilder (https://github.com/Subito-it/PodBuilder)", "# Please don't modify this file", "\n"]
|
156
158
|
podfile_content += analyzer.podfile.sources.map { |x| "source '#{x}'" }
|
157
159
|
podfile_content += ["", "use_frameworks!", ""]
|
@@ -191,7 +193,7 @@ module PodBuilder
|
|
191
193
|
if Configuration.react_native_project
|
192
194
|
return write_prebuilt_react_native(all_buildable_items, analyzer)
|
193
195
|
end
|
194
|
-
|
196
|
+
|
195
197
|
puts "Updating Application Podfile".yellow
|
196
198
|
|
197
199
|
explicit_deps = analyzer.explicit_pods()
|
@@ -199,7 +201,7 @@ module PodBuilder
|
|
199
201
|
explicit_deps.uniq!
|
200
202
|
podbuilder_podfile_path = PodBuilder::basepath("Podfile")
|
201
203
|
rel_path = Pathname.new(podbuilder_podfile_path).relative_path_from(Pathname.new(PodBuilder::project_path)).to_s
|
202
|
-
|
204
|
+
|
203
205
|
podfile_content = File.read(podbuilder_podfile_path)
|
204
206
|
|
205
207
|
exclude_lines = Podfile::PODBUILDER_LOCK_ACTION.map { |x| strip_line(x) }
|
@@ -211,32 +213,32 @@ module PodBuilder
|
|
211
213
|
next
|
212
214
|
end
|
213
215
|
|
214
|
-
if pod_name = pod_definition_in(line, true)
|
216
|
+
if pod_name = pod_definition_in(line, true)
|
215
217
|
if podfile_item = all_buildable_items.detect { |x| x.name == pod_name }
|
216
218
|
marker = podfile_item.prebuilt_marker()
|
217
219
|
|
218
220
|
non_explicit_dependencies = podfile_item.recursive_dependencies(all_buildable_items) - explicit_deps
|
219
221
|
non_explicit_dependencies_root_names = non_explicit_dependencies.map(&:root_name).uniq.filter { |t| t != podfile_item.root_name }
|
220
|
-
non_explicit_dependencies = non_explicit_dependencies_root_names.map { |x|
|
222
|
+
non_explicit_dependencies = non_explicit_dependencies_root_names.map { |x|
|
221
223
|
if item = all_buildable_items.detect { |t| x == t.name }
|
222
|
-
item
|
224
|
+
item
|
223
225
|
else
|
224
226
|
item = all_buildable_items.detect { |t| x == t.root_name }
|
225
227
|
end
|
226
228
|
}.compact
|
227
|
-
|
229
|
+
|
228
230
|
non_explicit_dependencies.each do |dep|
|
229
231
|
dep_item = all_buildable_items.detect { |x| x.name == dep.name }
|
230
232
|
|
231
|
-
if File.exist?(dep_item.prebuilt_podspec_path) && !dep_item.is_prebuilt
|
233
|
+
if File.exist?(dep_item.prebuilt_podspec_path) && !dep_item.is_prebuilt
|
232
234
|
pod_name = dep_item.prebuilt_entry(false, false)
|
233
235
|
prebuilt_lines.push("#{line.detect_indentation}#{pod_name}#{marker}\n")
|
234
236
|
end
|
235
237
|
|
236
238
|
explicit_deps.push(dep)
|
237
|
-
end
|
239
|
+
end
|
238
240
|
|
239
|
-
if File.exist?(podfile_item.prebuilt_podspec_path) && !podfile_item.is_prebuilt
|
241
|
+
if File.exist?(podfile_item.prebuilt_podspec_path) && !podfile_item.is_prebuilt
|
240
242
|
prebuilt_lines.push("#{line.detect_indentation}#{podfile_item.prebuilt_entry}\n")
|
241
243
|
next
|
242
244
|
end
|
@@ -256,7 +258,7 @@ module PodBuilder
|
|
256
258
|
File.write(project_podfile_path, podfile_content)
|
257
259
|
end
|
258
260
|
|
259
|
-
def self.write_prebuilt_react_native(all_buildable_items, analyzer)
|
261
|
+
def self.write_prebuilt_react_native(all_buildable_items, analyzer)
|
260
262
|
puts "Updating Application Podfile".yellow
|
261
263
|
|
262
264
|
podbuilder_podfile_path = PodBuilder::basepath("Podfile")
|
@@ -278,7 +280,7 @@ module PodBuilder
|
|
278
280
|
|
279
281
|
Dir.chdir(PodBuilder::project_path) do
|
280
282
|
bundler_prefix = Configuration.use_bundler ? "bundle exec " : ""
|
281
|
-
|
283
|
+
|
282
284
|
if Configuration.react_native_project
|
283
285
|
system("#{bundler_prefix}pod deintegrate;")
|
284
286
|
end
|
@@ -295,7 +297,7 @@ module PodBuilder
|
|
295
297
|
def self.pod_definition_in(line, include_commented)
|
296
298
|
stripped_line = strip_line(line)
|
297
299
|
matches = stripped_line.match(/(^pod')(.*?)(')/)
|
298
|
-
|
300
|
+
|
299
301
|
if matches&.size == 4 && (include_commented || !stripped_line.start_with?("#"))
|
300
302
|
return matches[2]
|
301
303
|
else
|
@@ -320,7 +322,7 @@ module PodBuilder
|
|
320
322
|
restore_content.each_line do |line|
|
321
323
|
if pod_name = pod_definition_in(line, false)
|
322
324
|
if pod_items.map(&:name).include?(pod_name)
|
323
|
-
cleaned_lines.push(line)
|
325
|
+
cleaned_lines.push(line)
|
324
326
|
end
|
325
327
|
else
|
326
328
|
cleaned_lines.push(line)
|
@@ -406,7 +408,7 @@ module PodBuilder
|
|
406
408
|
# resolve potentially wrong pod name case
|
407
409
|
podfile_path = PodBuilder::basepath("Podfile")
|
408
410
|
content = File.read(podfile_path)
|
409
|
-
|
411
|
+
|
410
412
|
current_section = ""
|
411
413
|
content.each_line do |line|
|
412
414
|
matches = line.gsub("\"", "'").match(/pod '(.*?)'/)
|
@@ -449,7 +451,7 @@ module PodBuilder
|
|
449
451
|
end
|
450
452
|
|
451
453
|
return replace_path
|
452
|
-
end
|
454
|
+
end
|
453
455
|
|
454
456
|
def self.indentation_from_string(content)
|
455
457
|
lines = content.split("\n").select { |x| !x.empty? }
|
@@ -462,7 +464,7 @@ module PodBuilder
|
|
462
464
|
|
463
465
|
if current_doesnt_begin_with_whitespace && [" ", "\t"].include?(next_line_first_char)
|
464
466
|
return next_line[/\A\s*/]
|
465
|
-
end
|
467
|
+
end
|
466
468
|
end
|
467
469
|
end
|
468
470
|
|
@@ -491,17 +493,17 @@ module PodBuilder
|
|
491
493
|
buildable_items = []
|
492
494
|
begin
|
493
495
|
installer, analyzer = Analyze.installer_at(PodBuilder::basepath)
|
494
|
-
|
496
|
+
|
495
497
|
podfile_items = Analyze.podfile_items(installer, analyzer)
|
496
|
-
buildable_items = podfile_items.select { |item| include_prebuilt || !item.is_prebuilt }
|
498
|
+
buildable_items = podfile_items.select { |item| include_prebuilt || !item.is_prebuilt }
|
497
499
|
rescue Exception => e
|
498
500
|
raise e
|
499
501
|
ensure
|
500
502
|
Dir.chdir(current_dir)
|
501
|
-
|
503
|
+
|
502
504
|
if File.basename(podfile_path) != "Podfile"
|
503
505
|
File.rename(PodBuilder::basepath("Podfile.tmp"), PodBuilder::basepath("Podfile"))
|
504
|
-
end
|
506
|
+
end
|
505
507
|
end
|
506
508
|
|
507
509
|
return buildable_items
|
@@ -522,7 +524,7 @@ module PodBuilder
|
|
522
524
|
def self.add(entries, marker, podfile_content)
|
523
525
|
file_indentation = indentation_from_string(podfile_content)
|
524
526
|
|
525
|
-
entries = entries.map { |x| "#{file_indentation}#{x}\n"}
|
527
|
+
entries = entries.map { |x| "#{file_indentation}#{x}\n" }
|
526
528
|
|
527
529
|
marker_found = false
|
528
530
|
podfile_lines = []
|
@@ -547,7 +549,7 @@ module PodBuilder
|
|
547
549
|
|
548
550
|
return podfile_lines.join
|
549
551
|
end
|
550
|
-
|
552
|
+
|
551
553
|
def self.update_path_entries(podfile_content, path_transform)
|
552
554
|
regex = "(\s*pod\s*['|\"])(.*?)(['|\"])(.*?):(path|podspec)(\s*=>\s*['|\"])(.*?)(['|\"])"
|
553
555
|
|
@@ -567,7 +569,7 @@ module PodBuilder
|
|
567
569
|
end
|
568
570
|
|
569
571
|
replace_path = path_transform.call(path)
|
570
|
-
|
572
|
+
|
571
573
|
updated_path_line = line.gsub(/#{regex}/, '\1\2\3\4:\5\6' + replace_path.to_s + '\8\9')
|
572
574
|
podfile_lines.push(updated_path_line)
|
573
575
|
else
|
@@ -578,7 +580,7 @@ module PodBuilder
|
|
578
580
|
return podfile_lines.join
|
579
581
|
end
|
580
582
|
|
581
|
-
def self.update_project_entries(podfile_content, path_transform)
|
583
|
+
def self.update_project_entries(podfile_content, path_transform)
|
582
584
|
regex = "(\s*project\s*['|\"])(.*?)(['|\"])"
|
583
585
|
|
584
586
|
podfile_lines = []
|
@@ -596,7 +598,7 @@ module PodBuilder
|
|
596
598
|
end
|
597
599
|
|
598
600
|
replace_path = path_transform.call(path)
|
599
|
-
|
601
|
+
|
600
602
|
updated_path_line = line.gsub(/#{regex}/, '\1' + replace_path.to_s + '\3\4')
|
601
603
|
podfile_lines.push(updated_path_line)
|
602
604
|
else
|
@@ -627,7 +629,7 @@ module PodBuilder
|
|
627
629
|
end
|
628
630
|
|
629
631
|
replace_path = path_transform.call(path)
|
630
|
-
|
632
|
+
|
631
633
|
updated_path_line = line.gsub(/#{regex}/, '\1' + replace_path.to_s + '\3\4')
|
632
634
|
podfile_lines.push(updated_path_line)
|
633
635
|
else
|
@@ -648,7 +650,7 @@ module PodBuilder
|
|
648
650
|
config_dest_path = PodBuilder::basepath("rn_config.json")
|
649
651
|
|
650
652
|
raise "\n\nFailed generating react native configuration file\n".red unless system("node '#{bin_js}' config > #{config_dest_path}")
|
651
|
-
|
653
|
+
|
652
654
|
content = File.read(config_dest_path)
|
653
655
|
|
654
656
|
content.gsub!(PodBuilder::project_path, "..")
|
@@ -657,11 +659,11 @@ module PodBuilder
|
|
657
659
|
json = JSON.parse(content)
|
658
660
|
begin
|
659
661
|
json["project"]["ios"]["sourceDir"] = "./"
|
660
|
-
json["project"]["ios"]["podfile"] = "./"
|
662
|
+
json["project"]["ios"]["podfile"] = "./"
|
661
663
|
rescue => exception
|
662
664
|
raise "\n\nFailed updating react native configuration json\n".red
|
663
665
|
end
|
664
|
-
|
666
|
+
|
665
667
|
File.write(config_dest_path, JSON.pretty_generate(json))
|
666
668
|
|
667
669
|
return "rn_config = JSON.load(File.read(\"rn_config.json\")) # pb added\n\n" + podfile_content
|
@@ -710,7 +712,7 @@ module PodBuilder
|
|
710
712
|
unless matches&.size == 2
|
711
713
|
return podfile_content
|
712
714
|
end
|
713
|
-
|
715
|
+
|
714
716
|
indentation = matches[1]
|
715
717
|
lines.push("#{indentation}use_native_modules!(rn_config) # pb added\n")
|
716
718
|
lines.push("#{indentation}# #{line.strip} # pb removed\n")
|
@@ -744,7 +746,7 @@ module PodBuilder
|
|
744
746
|
end
|
745
747
|
|
746
748
|
def self.prepare_react_native_compilation_workarounds(podfile_content)
|
747
|
-
|
749
|
+
podfile_content += "" "
|
748
750
|
|
749
751
|
def prepare_rn_react_codegen
|
750
752
|
# Beginning with version 0.68.0 react native project compilation relies on some autogenerated files
|
@@ -773,13 +775,14 @@ def replace(path, find, replace)
|
|
773
775
|
File.write(path, content)
|
774
776
|
end
|
775
777
|
end
|
778
|
+
" ""
|
776
779
|
|
777
|
-
pre_install
|
780
|
+
pre_install = "" "
|
778
781
|
require 'json'
|
779
782
|
|
780
783
|
pods_path = \"#{PodBuilder::project_path}/Pods\"
|
781
|
-
j = JSON.parse(File.read(\"\#{pods_path}/Local Podspecs/FBReactNativeSpec.podspec.json\"))
|
782
|
-
|
784
|
+
j = JSON.parse(File.read(\"\#{pods_path}/Local Podspecs/FBReactNativeSpec.podspec.json\"))
|
785
|
+
|
783
786
|
output_files = j.dig(\"script_phases\", \"output_files\")
|
784
787
|
|
785
788
|
script_lines = j.dig(\"script_phases\", \"script\").split(\"\\n\")
|
@@ -787,14 +790,14 @@ pre_install do |installer|
|
|
787
790
|
script_lines.insert(0, \"export DERIVED_FILE_DIR=/tmp\")
|
788
791
|
script_lines.insert(0, \"export PODS_TARGET_SRCROOT=\\\"#{PodBuilder::project_path}/../node_modules/react-native/React/FBReactNativeSpec\\\"\")
|
789
792
|
script_lines.insert(0, \"export PODS_ROOT=\\\"\#{pods_path}\\\"\")
|
790
|
-
|
793
|
+
|
791
794
|
Dir.chdir(pods_path) do
|
792
795
|
cmd = script_lines.reject(&:blank?).join(\";\\n\")
|
793
796
|
system(cmd)
|
794
797
|
end
|
795
|
-
|
798
|
+
" ""
|
796
799
|
|
797
|
-
post_install
|
800
|
+
post_install = "" "
|
798
801
|
prepare_rn_compilation_libevent()
|
799
802
|
prepare_rn_flipper_module_redefinition()
|
800
803
|
prepare_rn_react_codegen()
|
@@ -812,8 +815,12 @@ post_install do |installer|
|
|
812
815
|
end
|
813
816
|
end
|
814
817
|
end
|
815
|
-
|
816
|
-
|
818
|
+
" ""
|
819
|
+
|
820
|
+
podfile_content.gsub!("pre_install do |installer|", "pre_install do |installer|\n" + "#{pre_install}\n")
|
821
|
+
podfile_content.gsub!("post_install do |installer|", "post_install do |installer|\n" + "#{post_install}\n")
|
822
|
+
|
823
|
+
return podfile_content
|
817
824
|
end
|
818
825
|
end
|
819
826
|
end
|