pod-builder 3.0.0 ā 3.4.0
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/README.md +23 -5
- data/exe/pod_builder +0 -3
- data/lib/pod_builder/analyze.rb +12 -13
- data/lib/pod_builder/command/build.rb +73 -23
- data/lib/pod_builder/command/deintegrate.rb +11 -9
- data/lib/pod_builder/command/generate_lldbinit.rb +1 -1
- data/lib/pod_builder/command/init.rb +7 -6
- data/lib/pod_builder/command/install_sources.rb +9 -11
- data/lib/pod_builder/command/switch.rb +37 -16
- data/lib/pod_builder/command/sync_podfile.rb +11 -11
- data/lib/pod_builder/command/update.rb +0 -1
- data/lib/pod_builder/configuration.rb +10 -2
- data/lib/pod_builder/core.rb +4 -3
- data/lib/pod_builder/info.rb +1 -1
- data/lib/pod_builder/install.rb +65 -37
- data/lib/pod_builder/licenses.rb +4 -4
- data/lib/pod_builder/podfile.rb +21 -15
- data/lib/pod_builder/podfile/pre_actions_swizzles.rb +1 -1
- data/lib/pod_builder/podfile_item.rb +69 -36
- data/lib/pod_builder/podspec.rb +1 -1
- data/lib/pod_builder/post_actions.rb +46 -0
- data/lib/pod_builder/rome/post_install.rb +11 -11
- data/lib/pod_builder/version.rb +1 -1
- metadata +4 -3
@@ -12,17 +12,17 @@ module PodBuilder
|
|
12
12
|
|
13
13
|
all_buildable_items = Analyze.podfile_items(installer, analyzer)
|
14
14
|
|
15
|
-
Dir.chdir(PodBuilder::project_path)
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
15
|
+
Dir.chdir(PodBuilder::project_path) do
|
16
|
+
previous_podfile_content = File.read("Podfile")
|
17
|
+
Podfile::write_prebuilt(all_buildable_items, analyzer)
|
18
|
+
updated_podfile_content = File.read("Podfile")
|
19
|
+
|
20
|
+
Licenses::write([], all_buildable_items)
|
21
|
+
|
22
|
+
if previous_podfile_content != updated_podfile_content
|
23
|
+
bundler_prefix = Configuration.use_bundler ? "bundle exec " : ""
|
24
|
+
system("#{bundler_prefix}pod install;")
|
25
|
+
end
|
26
26
|
end
|
27
27
|
|
28
28
|
puts "\n\nš done!\n".green
|
@@ -75,6 +75,7 @@ module PodBuilder
|
|
75
75
|
attr_accessor :build_xcframeworks_all
|
76
76
|
attr_accessor :build_xcframeworks_include
|
77
77
|
attr_accessor :build_xcframeworks_exclude
|
78
|
+
attr_accessor :post_actions
|
78
79
|
end
|
79
80
|
|
80
81
|
@build_settings = DEFAULT_BUILD_SETTINGS
|
@@ -111,6 +112,8 @@ module PodBuilder
|
|
111
112
|
@build_xcframeworks_all = false
|
112
113
|
@build_xcframeworks_include = []
|
113
114
|
@build_xcframeworks_exclude = []
|
115
|
+
|
116
|
+
@post_actions = {}
|
114
117
|
|
115
118
|
def self.check_inited
|
116
119
|
raise "\n\nNot inited, run `pod_builder init`\n".red if podbuilder_path.nil?
|
@@ -229,6 +232,11 @@ module PodBuilder
|
|
229
232
|
Configuration.build_xcframeworks_exclude = value
|
230
233
|
end
|
231
234
|
end
|
235
|
+
if value = json["post_actions"]
|
236
|
+
if value.is_a?(Hash)
|
237
|
+
Configuration.post_actions = PodBuilder::PostActions.load(value)
|
238
|
+
end
|
239
|
+
end
|
232
240
|
|
233
241
|
Configuration.build_settings.freeze
|
234
242
|
|
@@ -286,9 +294,9 @@ module PodBuilder
|
|
286
294
|
end
|
287
295
|
end
|
288
296
|
if Configuration.build_xcframeworks_all
|
289
|
-
raise "
|
297
|
+
raise "\n\nInvalid PodBuilder.json configuration: 'build_xcframeworks_all' is true and 'build_xcframeworks_include' is not empty\n".red if Configuration.build_xcframeworks_include.count > 0
|
290
298
|
else
|
291
|
-
raise "
|
299
|
+
raise "\n\nInvalid PodBuilder.json configuration: 'build_xcframeworks_all' is false and 'build_xcframeworks_exclude' is not empty\n".red if Configuration.build_xcframeworks_exclude.count > 0
|
292
300
|
end
|
293
301
|
end
|
294
302
|
|
data/lib/pod_builder/core.rb
CHANGED
@@ -12,6 +12,7 @@ require 'pod_builder/info'
|
|
12
12
|
require 'pod_builder/configuration'
|
13
13
|
require 'pod_builder/podspec'
|
14
14
|
require 'pod_builder/licenses'
|
15
|
+
require 'pod_builder/post_actions'
|
15
16
|
|
16
17
|
require 'core_ext/string'
|
17
18
|
|
@@ -132,7 +133,7 @@ module PodBuilder
|
|
132
133
|
folder_in_home = x.gsub(home, "")
|
133
134
|
!folder_in_home.include?("/Pods/") && !x.include?(PodBuilder::basepath("Sources")) && !x.include?(PodBuilder::basepath + "/")
|
134
135
|
}
|
135
|
-
raise "\n\nxcodeproj not found
|
136
|
+
raise "\n\nxcodeproj not found!\n".red if xcodeprojects.count == 0
|
136
137
|
raise "\n\nFound multiple xcodeproj:\n#{xcodeprojects.join("\n")}".red if xcodeprojects.count > 1
|
137
138
|
|
138
139
|
@@xcodeproj_path = xcodeprojects.first
|
@@ -148,7 +149,7 @@ module PodBuilder
|
|
148
149
|
folder_in_home = x.gsub(home, "")
|
149
150
|
!folder_in_home.include?("/Pods/") && !x.include?(PodBuilder::basepath("Sources")) && !x.include?(PodBuilder::basepath + "/") && !x.include?(".xcodeproj/")
|
150
151
|
}
|
151
|
-
raise "\n\nxcworkspace not found
|
152
|
+
raise "\n\nxcworkspace not found!\n".red if xcworkspaces.count == 0
|
152
153
|
raise "\n\nFound multiple xcworkspaces:\n#{xcworkspaces.join("\n")}".red if xcworkspaces.count > 1
|
153
154
|
|
154
155
|
@@xcodeworkspace_path = xcworkspaces.first
|
@@ -179,7 +180,7 @@ module PodBuilder
|
|
179
180
|
|
180
181
|
def self.system_swift_version
|
181
182
|
swift_version = `swiftc --version | grep -o 'swiftlang-.*\s'`.strip()
|
182
|
-
raise "\n\nUnsupported swift compiler version, expecting `swiftlang` keyword in `swiftc --version
|
183
|
+
raise "\n\nUnsupported swift compiler version, expecting `swiftlang` keyword in `swiftc --version`\n".red if swift_version.length == 0
|
183
184
|
return swift_version
|
184
185
|
end
|
185
186
|
|
data/lib/pod_builder/info.rb
CHANGED
data/lib/pod_builder/install.rb
CHANGED
@@ -45,7 +45,7 @@ begin
|
|
45
45
|
elsif defined?(Pod::Target::BuildType) # CocoaPods 1.7, 1.8
|
46
46
|
Pod::Target::BuildType.new(linkage: :dynamic, packaging: :framework)
|
47
47
|
else
|
48
|
-
raise "\n\nBuildType not found. Open an issue reporting your CocoaPods version".red
|
48
|
+
raise "\n\nBuildType not found. Open an issue reporting your CocoaPods version\n".red
|
49
49
|
end
|
50
50
|
else
|
51
51
|
swz_build_type()
|
@@ -139,7 +139,7 @@ module PodBuilder
|
|
139
139
|
|
140
140
|
class Install
|
141
141
|
# This method will generate prebuilt data by building from "/tmp/pod_builder/Podfile"
|
142
|
-
def self.podfile(podfile_content, podfile_items, build_configuration)
|
142
|
+
def self.podfile(podfile_content, podfile_items, argument_pods, build_configuration)
|
143
143
|
puts "Preparing build Podfile".yellow
|
144
144
|
|
145
145
|
PodBuilder::safe_rm_rf(Configuration.build_path)
|
@@ -160,7 +160,7 @@ module PodBuilder
|
|
160
160
|
lock_file = "#{Configuration.build_path}/pod_builder.lock"
|
161
161
|
FileUtils.touch(lock_file)
|
162
162
|
|
163
|
-
prebuilt_entries = use_prebuilt_entries_for_unchanged_pods(podfile_path, podfile_items)
|
163
|
+
prebuilt_entries = use_prebuilt_entries_for_unchanged_pods(podfile_path, podfile_items, argument_pods)
|
164
164
|
|
165
165
|
install
|
166
166
|
|
@@ -247,7 +247,7 @@ module PodBuilder
|
|
247
247
|
def self.license_specifiers
|
248
248
|
acknowledge_file = "#{Configuration.build_path}/Pods/Target Support Files/Pods-DummyTarget/Pods-DummyTarget-acknowledgements.plist"
|
249
249
|
unless File.exist?(acknowledge_file)
|
250
|
-
raise "\n\nLicense file not found".red
|
250
|
+
raise "\n\nLicense file not found\n".red
|
251
251
|
end
|
252
252
|
|
253
253
|
plist = CFPropertyList::List.new(:file => acknowledge_file)
|
@@ -280,45 +280,67 @@ module PodBuilder
|
|
280
280
|
return podfile_content
|
281
281
|
end
|
282
282
|
|
283
|
-
def self.use_prebuilt_entries_for_unchanged_pods(podfile_path, podfile_items)
|
283
|
+
def self.use_prebuilt_entries_for_unchanged_pods(podfile_path, podfile_items, argument_pods)
|
284
284
|
podfile_content = File.read(podfile_path)
|
285
285
|
|
286
286
|
replaced_items = []
|
287
287
|
|
288
|
-
|
289
|
-
podfile_content.gsub!("%%%prebuilt_root_paths%%%", "{}")
|
290
|
-
else
|
291
|
-
download # Copy files under #{Configuration.build_path}/Pods so that we can determine build folder hashes
|
288
|
+
download # Copy files under #{Configuration.build_path}/Pods so that we can determine build folder hashes
|
292
289
|
|
293
|
-
|
290
|
+
gitignored_files = PodBuilder::gitignoredfiles
|
294
291
|
|
295
|
-
|
292
|
+
prebuilt_root_paths = Hash.new
|
296
293
|
|
297
|
-
|
298
|
-
|
299
|
-
items.each do |item|
|
300
|
-
podspec_path = item.prebuilt_podspec_path
|
301
|
-
if last_build_folder_hash = build_folder_hash_in_prebuilt_info_file(item)
|
302
|
-
if last_build_folder_hash == build_folder_hash(item, gitignored_files)
|
303
|
-
puts "No changes detected to '#{item.root_name}', will skip rebuild".blue
|
294
|
+
puts "Optimizing build".yellow
|
295
|
+
puts "Build strategy".blue
|
304
296
|
|
305
|
-
|
297
|
+
prebuild_log = lambda { |item, reason|
|
298
|
+
if item.is_prebuilt
|
299
|
+
puts "#{item.root_name} is prebuilt"
|
300
|
+
else
|
301
|
+
puts "#{item.root_name} from source #{reason}".blue
|
302
|
+
end
|
303
|
+
}
|
306
304
|
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
podfile_content.gsub!(/#{replace_regex}/, replace_item.prebuilt_entry(true, true))
|
305
|
+
# Replace prebuilt entries in Podfile for Pods that have no changes in source code which will avoid rebuilding them
|
306
|
+
items = podfile_items.group_by { |t| t.root_name }.map { |k, v| v.first }.sort_by { |t| t.root_name } # Return one podfile_item per root_name
|
307
|
+
if OPTIONS.has_key?(:force_rebuild)
|
308
|
+
rebuild_pods = items.select { |t| argument_pods.include?(t.root_name) }
|
312
309
|
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
310
|
+
rebuild_pods.each do |item|
|
311
|
+
prebuild_log.call(item, "")
|
312
|
+
end
|
313
|
+
|
314
|
+
items -= rebuild_pods
|
315
|
+
end
|
316
|
+
|
317
|
+
items.each do |item|
|
318
|
+
podspec_path = item.prebuilt_podspec_path
|
319
|
+
unless last_build_folder_hash = build_folder_hash_in_prebuilt_info_file(item)
|
320
|
+
prebuild_log.call(item, "(folder hash missing)")
|
321
|
+
next
|
317
322
|
end
|
323
|
+
|
324
|
+
if last_build_folder_hash == build_folder_hash(item, gitignored_files)
|
325
|
+
puts "#{item.root_name} reuse PodBuilder cache"
|
326
|
+
|
327
|
+
replaced_items.push(item)
|
318
328
|
|
319
|
-
|
329
|
+
podfile_items.select { |t| t.root_name == item.root_name }.each do |replace_item|
|
330
|
+
replace_regex = "pod '#{Regexp.quote(replace_item.name)}', .*"
|
331
|
+
replace_line_found = podfile_content =~ /#{replace_regex}/i
|
332
|
+
raise "\n\nFailed finding pod entry for '#{replace_item.name}'\n".red unless replace_line_found
|
333
|
+
podfile_content.gsub!(/#{replace_regex}/, replace_item.prebuilt_entry(true, true))
|
334
|
+
|
335
|
+
prebuilt_root_paths[replace_item.root_name] = PodBuilder::prebuiltpath
|
336
|
+
end
|
337
|
+
else
|
338
|
+
prebuild_log.call(item, "(folder hash mismatch)")
|
339
|
+
end
|
320
340
|
end
|
321
341
|
|
342
|
+
podfile_content.gsub!("%%%prebuilt_root_paths%%%", prebuilt_root_paths.to_s)
|
343
|
+
|
322
344
|
File.write(podfile_path, podfile_content)
|
323
345
|
|
324
346
|
return replaced_items
|
@@ -402,6 +424,13 @@ module PodBuilder
|
|
402
424
|
end
|
403
425
|
end
|
404
426
|
|
427
|
+
# Cleanup unneeded files (see https://github.com/bazelbuild/rules_apple/pull/1113)
|
428
|
+
ignore_files = Dir.glob(["#{source_path}/**/Modules/**/*.swiftmodule/*.swiftdoc", "#{source_path}/**/Modules/**/*.swiftmodule/**/*.swiftsourceinfo"])
|
429
|
+
ignore_files.each { |t| PodBuilder::safe_rm_rf(t) }
|
430
|
+
|
431
|
+
project_folder = Dir.glob("#{source_path}/**/Modules/**/*.swiftmodule/Project")
|
432
|
+
project_folder.select { |t| File.directory?(t) && Dir.empty?(t) }.each { |t| PodBuilder::safe_rm_rf(t) }
|
433
|
+
|
405
434
|
unless Dir.glob("#{source_path}/**/*").select { |t| File.file?(t) }.empty?
|
406
435
|
destination_folder = PodBuilder::prebuiltpath(root_name)
|
407
436
|
FileUtils.mkdir_p(destination_folder)
|
@@ -425,11 +454,9 @@ module PodBuilder
|
|
425
454
|
end
|
426
455
|
|
427
456
|
def self.init_git(path)
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
system("git init")
|
432
|
-
Dir.chdir(current_dir)
|
457
|
+
Dir.chdir(path) do
|
458
|
+
system("git init")
|
459
|
+
end
|
433
460
|
end
|
434
461
|
|
435
462
|
def self.build_folder_hash_in_prebuilt_info_file(podfile_item)
|
@@ -457,15 +484,16 @@ module PodBuilder
|
|
457
484
|
unless File.file?(path)
|
458
485
|
next
|
459
486
|
end
|
460
|
-
|
487
|
+
|
461
488
|
path = File.expand_path(path)
|
462
489
|
rel_path = path.gsub(rootpath, "")[1..]
|
463
|
-
|
490
|
+
|
491
|
+
unless exclude_files.any? { |t| rel_path.start_with?(t) }
|
464
492
|
file_hashes.push(Digest::MD5.hexdigest(File.read(path)))
|
465
493
|
end
|
466
494
|
end
|
467
495
|
|
468
|
-
return Digest::MD5.hexdigest(file_hashes.join)
|
496
|
+
return Digest::MD5.hexdigest(file_hashes.sort.join)
|
469
497
|
else
|
470
498
|
# Pod folder might be under .gitignore
|
471
499
|
item_path = "#{Configuration.build_path}/Pods/#{podfile_item.root_name}"
|
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 "\n\nUnexpected license found in header".red if licenses_header.has_key?("License")
|
15
|
+
raise "\n\nUnexpected license found in header\n".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 "\n\nUnexpected license found in footer".red if license_footer.has_key?("License")
|
19
|
+
raise "\n\nUnexpected license found in footer\n".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 "\n\nUnexpected license found in header".red if licenses_header.has_key?("License")
|
25
|
+
raise "\n\nUnexpected license found in header\n".red if licenses_header.has_key?("License")
|
26
26
|
license_footer = licenses.pop
|
27
|
-
raise "\n\nUnexpected license found in footer".red if license_footer.has_key?("License")
|
27
|
+
raise "\n\nUnexpected license found in footer\n".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
@@ -6,7 +6,7 @@ module PodBuilder
|
|
6
6
|
PRE_INSTALL_ACTIONS = ["Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_duplicate_framework_and_library_names) {}", "require 'pod_builder/podfile/pre_actions_swizzles'"].freeze
|
7
7
|
|
8
8
|
def self.from_podfile_items(items, analyzer, build_configuration, install_using_frameworks, build_catalyst, build_xcframeworks)
|
9
|
-
raise "\n\nno items".red unless items.count > 0
|
9
|
+
raise "\n\nno items\n".red unless items.count > 0
|
10
10
|
|
11
11
|
sources = analyzer.sources
|
12
12
|
|
@@ -34,7 +34,7 @@ module PodBuilder
|
|
34
34
|
items.each do |item|
|
35
35
|
build_settings = Configuration.build_settings.dup
|
36
36
|
|
37
|
-
item_build_settings = Configuration.build_settings_overrides[item.name] || {}
|
37
|
+
item_build_settings = Configuration.build_settings_overrides[item.name].dup || {}
|
38
38
|
|
39
39
|
# These settings need to be set as is to properly build frameworks
|
40
40
|
build_settings["SWIFT_COMPILATION_MODE"] = "wholemodule"
|
@@ -46,10 +46,6 @@ module PodBuilder
|
|
46
46
|
|
47
47
|
build_settings["IPHONEOS_DEPLOYMENT_TARGET"] = platform.deployment_target.version # Fix compilation warnings on Xcode 12
|
48
48
|
|
49
|
-
# Don't store .pcm info in binary, see https://forums.swift.org/t/swift-behavior-of-gmodules-and-dsyms/23211/3
|
50
|
-
build_settings["CLANG_ENABLE_MODULE_DEBUGGING"] = "NO"
|
51
|
-
build_settings["OTHER_SWIFT_FLAGS"] = "$(inherited) -Xfrontend -no-clang-module-breadcrumbs"
|
52
|
-
|
53
49
|
# Ignore deprecation warnings
|
54
50
|
build_settings["GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS"] = "NO"
|
55
51
|
|
@@ -70,10 +66,20 @@ module PodBuilder
|
|
70
66
|
build_settings["BITCODE_GENERATION_MODE"] = "bitcode"
|
71
67
|
end
|
72
68
|
|
69
|
+
# Don't store .pcm info in binary, see https://forums.swift.org/t/swift-behavior-of-gmodules-and-dsyms/23211/3
|
70
|
+
build_settings["CLANG_ENABLE_MODULE_DEBUGGING"] = "NO"
|
71
|
+
other_swift_flags_override = " $(inherited) -Xfrontend -no-clang-module-breadcrumbs"
|
72
|
+
|
73
73
|
item_build_settings.each do |k, v|
|
74
|
-
|
74
|
+
# Do not allow to override above settings which are mandatory for a correct compilation
|
75
|
+
if build_settings[k].nil?
|
76
|
+
build_settings[k] = v
|
77
|
+
end
|
75
78
|
end
|
76
79
|
|
80
|
+
# All the below settings should be merged with global (Configuration.build_settings) or per pod build_settings (Configuration.build_settings_overrides)
|
81
|
+
build_settings["OTHER_SWIFT_FLAGS"] = build_settings.fetch("OTHER_SWIFT_FLAGS", "") + other_swift_flags_override
|
82
|
+
|
77
83
|
podfile_build_settings += "set_build_settings(\"#{item.root_name}\", #{build_settings.to_s}, installer)\n "
|
78
84
|
|
79
85
|
dependency_names = item.dependency_names.map { |x|
|
@@ -354,7 +360,7 @@ module PodBuilder
|
|
354
360
|
|
355
361
|
if stripped_line.match(/(pod')(.*?)(')/) != nil
|
356
362
|
starting_def_found = stripped_line.start_with?("def") && (line.match("\s*def\s") != nil)
|
357
|
-
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
|
363
|
+
raise "\n\nUnsupported single line def/pod. `def` and `pod` shouldn't be on the same line, please modify the following line:\n#{line}\n".red if starting_def_found
|
358
364
|
end
|
359
365
|
end
|
360
366
|
end
|
@@ -396,9 +402,9 @@ module PodBuilder
|
|
396
402
|
if target_settings.count == 1
|
397
403
|
return target_settings.first
|
398
404
|
elsif target_settings.count > 1
|
399
|
-
raise "\n\n'use_frameworks!' should be declared only once at Podfile root level (not nested in targets)".red
|
405
|
+
raise "\n\n'use_frameworks!' should be declared only once at Podfile root level (not nested in targets)\n".red
|
400
406
|
else
|
401
|
-
raise "\n\nFailed detecting use_frameworks
|
407
|
+
raise "\n\nFailed detecting use_frameworks!\n".red
|
402
408
|
end
|
403
409
|
|
404
410
|
return true
|
@@ -443,13 +449,13 @@ module PodBuilder
|
|
443
449
|
def self.project_swift_version(analyzer)
|
444
450
|
swift_versions = analyzer.instance_variable_get("@result").targets.map { |x| x.target_definition.swift_version }.compact.uniq
|
445
451
|
|
446
|
-
raise "\n\nFound different Swift versions in targets. Expecting one, got `#{swift_versions}
|
452
|
+
raise "\n\nFound different Swift versions in targets. Expecting one, got `#{swift_versions}`\n".red if swift_versions.count > 1
|
447
453
|
|
448
454
|
return swift_versions.first || PodBuilder::system_swift_version
|
449
455
|
end
|
450
456
|
|
451
457
|
def self.podfile_items_at(podfile_path, include_prebuilt = false)
|
452
|
-
raise "\n\nExpecting basepath folder
|
458
|
+
raise "\n\nExpecting basepath folder!\n".red if !File.exist?(PodBuilder::basepath("Podfile"))
|
453
459
|
|
454
460
|
if File.basename(podfile_path) != "Podfile"
|
455
461
|
File.rename(PodBuilder::basepath("Podfile"), PodBuilder::basepath("Podfile.tmp"))
|
@@ -607,12 +613,12 @@ module PodBuilder
|
|
607
613
|
base = File.expand_path(File.join(PodBuilder::project_path, ".."))
|
608
614
|
bin_js = Dir.glob("#{base}/node_modules/@react-native-community/cli/build/bin.js")
|
609
615
|
|
610
|
-
raise "\n\nReact native cli bin_js not found! Did you run yarn install
|
616
|
+
raise "\n\nReact native cli bin_js not found! Did you run yarn install?\n".red unless bin_js.count == 1
|
611
617
|
bin_js = bin_js.first
|
612
618
|
|
613
619
|
config_dest_path = PodBuilder::basepath("rn_config.json")
|
614
620
|
|
615
|
-
raise "\n\nFailed generating react native configuration file".red unless system("node '#{bin_js}' config > #{config_dest_path}")
|
621
|
+
raise "\n\nFailed generating react native configuration file\n".red unless system("node '#{bin_js}' config > #{config_dest_path}")
|
616
622
|
|
617
623
|
content = File.read(config_dest_path)
|
618
624
|
|
@@ -624,7 +630,7 @@ module PodBuilder
|
|
624
630
|
json["project"]["ios"]["sourceDir"] = "./"
|
625
631
|
json["project"]["ios"]["podfile"] = "./"
|
626
632
|
rescue => exception
|
627
|
-
raise "\n\nFailed updating react native configuration json".red
|
633
|
+
raise "\n\nFailed updating react native configuration json\n".red
|
628
634
|
end
|
629
635
|
|
630
636
|
File.write(config_dest_path, JSON.pretty_generate(json))
|
@@ -24,7 +24,7 @@ class Pod::Generator::EmbedFrameworksScript
|
|
24
24
|
alias_method :swz_initialize, :initialize
|
25
25
|
|
26
26
|
def initialize(*args)
|
27
|
-
raise "
|
27
|
+
raise "\n\nUnsupported CocoaPods version\n".red if (args.count == 0 || args.count > 2)
|
28
28
|
|
29
29
|
frameworks_by_config = args[0]
|
30
30
|
frameworks_by_config.keys.each do |key|
|
@@ -138,6 +138,10 @@ module PodBuilder
|
|
138
138
|
# @return [Bool] Should build as xcframework
|
139
139
|
#
|
140
140
|
attr_accessor :build_xcframework
|
141
|
+
|
142
|
+
# @return [Bool] True if it's a pod that doesn't provide source code (is already shipped as a prebuilt pod)
|
143
|
+
#
|
144
|
+
attr_accessor :is_prebuilt
|
141
145
|
|
142
146
|
# Initialize a new instance
|
143
147
|
#
|
@@ -180,14 +184,26 @@ module PodBuilder
|
|
180
184
|
@weak_frameworks = []
|
181
185
|
@libraries = []
|
182
186
|
|
183
|
-
@frameworks += extract_array(spec, "framework")
|
184
|
-
@frameworks += extract_array(spec, "frameworks")
|
187
|
+
@frameworks += extract_array(spec.attributes_hash, "framework")
|
188
|
+
@frameworks += extract_array(spec.attributes_hash, "frameworks")
|
189
|
+
supported_platforms.each do |platform|
|
190
|
+
@frameworks += extract_array(spec.attributes_hash[platform], "framework")
|
191
|
+
@frameworks += extract_array(spec.attributes_hash[platform], "frameworks")
|
192
|
+
end
|
185
193
|
|
186
|
-
@weak_frameworks += extract_array(spec, "weak_framework")
|
187
|
-
@weak_frameworks += extract_array(spec, "weak_frameworks")
|
194
|
+
@weak_frameworks += extract_array(spec.attributes_hash, "weak_framework")
|
195
|
+
@weak_frameworks += extract_array(spec.attributes_hash, "weak_frameworks")
|
196
|
+
supported_platforms.each do |platform|
|
197
|
+
@weak_frameworks += extract_array(spec.attributes_hash[platform], "weak_framework")
|
198
|
+
@weak_frameworks += extract_array(spec.attributes_hash[platform], "weak_frameworks")
|
199
|
+
end
|
188
200
|
|
189
|
-
@libraries += extract_array(spec, "library")
|
190
|
-
@libraries += extract_array(spec, "libraries")
|
201
|
+
@libraries += extract_array(spec.attributes_hash, "library")
|
202
|
+
@libraries += extract_array(spec.attributes_hash, "libraries")
|
203
|
+
supported_platforms.each do |platform|
|
204
|
+
@libraries += extract_array(spec.attributes_hash[platform], "library")
|
205
|
+
@libraries += extract_array(spec.attributes_hash[platform], "libraries")
|
206
|
+
end
|
191
207
|
|
192
208
|
@header_dir = spec.attributes_hash["header_dir"]
|
193
209
|
|
@@ -197,7 +213,7 @@ module PodBuilder
|
|
197
213
|
@swift_version = spec.root.swift_version&.to_s
|
198
214
|
@module_name = spec.root.module_name
|
199
215
|
|
200
|
-
@default_subspecs = extract_array(spec, "default_subspecs")
|
216
|
+
@default_subspecs = extract_array(spec.attributes_hash, "default_subspecs")
|
201
217
|
if default_subspec = spec.attributes_hash["default_subspec"]
|
202
218
|
@default_subspecs.push(default_subspec)
|
203
219
|
end
|
@@ -246,6 +262,8 @@ module PodBuilder
|
|
246
262
|
build_as_xcframework = Configuration.build_xcframeworks_include.include?(@root_name)
|
247
263
|
end
|
248
264
|
@build_xcframework = build_as_xcframework
|
265
|
+
|
266
|
+
@is_prebuilt = extract_is_prebuilt(spec, all_specs, checkout_options, supported_platforms)
|
249
267
|
end
|
250
268
|
|
251
269
|
def pod_specification(all_poditems, parent_spec = nil)
|
@@ -335,33 +353,6 @@ module PodBuilder
|
|
335
353
|
return deps
|
336
354
|
end
|
337
355
|
|
338
|
-
# @return [Bool] True if it's a pod that doesn't provide source code (is already shipped as a prebuilt pod)
|
339
|
-
#
|
340
|
-
def is_prebuilt
|
341
|
-
if Configuration.force_prebuild_pods.include?(@root_name) || Configuration.force_prebuild_pods.include?(@name)
|
342
|
-
return false
|
343
|
-
end
|
344
|
-
|
345
|
-
# We treat pods to skip like prebuilt ones
|
346
|
-
if Configuration.skip_pods.include?(@root_name) || Configuration.skip_pods.include?(@name)
|
347
|
-
return true
|
348
|
-
end
|
349
|
-
|
350
|
-
# Podspecs aren't always properly written (source_file key is often used instead of header_files)
|
351
|
-
# Therefore it can become tricky to understand which pods are already precompiled by boxing a .framework or .a
|
352
|
-
embedded_as_vendored = vendored_frameworks.map { |x| File.basename(x) }.include?("#{module_name}.framework")
|
353
|
-
embedded_as_static_lib = vendored_libraries.map { |x| File.basename(x) }.include?("lib#{module_name}.a")
|
354
|
-
|
355
|
-
only_headers = (source_files.count > 0 && @source_files.all? { |x| x.end_with?(".h") })
|
356
|
-
no_sources = (@source_files.count == 0 || only_headers) && (@vendored_frameworks + @vendored_libraries).count > 0
|
357
|
-
|
358
|
-
if !no_sources && !only_headers
|
359
|
-
return false
|
360
|
-
else
|
361
|
-
return (no_sources || only_headers || embedded_as_static_lib || embedded_as_vendored)
|
362
|
-
end
|
363
|
-
end
|
364
|
-
|
365
356
|
# @return [Bool] True if it's a subspec
|
366
357
|
#
|
367
358
|
def is_subspec
|
@@ -472,6 +463,44 @@ module PodBuilder
|
|
472
463
|
|
473
464
|
private
|
474
465
|
|
466
|
+
# @return [Bool] True if it's a pod that doesn't provide source code (is already shipped as a prebuilt pod)
|
467
|
+
#
|
468
|
+
def extract_is_prebuilt(spec, all_specs, checkout_options, supported_platforms)
|
469
|
+
if Configuration.force_prebuild_pods.include?(@root_name) || Configuration.force_prebuild_pods.include?(@name)
|
470
|
+
return false
|
471
|
+
end
|
472
|
+
|
473
|
+
# We treat pods to skip like prebuilt ones
|
474
|
+
if Configuration.skip_pods.include?(@root_name) || Configuration.skip_pods.include?(@name)
|
475
|
+
return true
|
476
|
+
end
|
477
|
+
|
478
|
+
if default_subspecs != nil && default_subspecs.count > 0
|
479
|
+
default_subspecs.each do |default_subspec_name|
|
480
|
+
if (default_spec = all_specs.detect { |t| t.name == "#{root_name}/#{default_subspec_name}" })
|
481
|
+
default_item = PodfileItem.new(default_spec, all_specs, checkout_options, supported_platforms)
|
482
|
+
if default_item.is_prebuilt
|
483
|
+
return true
|
484
|
+
end
|
485
|
+
end
|
486
|
+
end
|
487
|
+
end
|
488
|
+
|
489
|
+
# Podspecs aren't always properly written (source_file key is often used instead of header_files)
|
490
|
+
# Therefore it can become tricky to understand which pods are already precompiled by boxing a .framework or .a
|
491
|
+
embedded_as_vendored = vendored_frameworks.map { |x| File.basename(x) }.include?("#{module_name}.framework")
|
492
|
+
embedded_as_static_lib = vendored_libraries.map { |x| File.basename(x) }.include?("lib#{module_name}.a")
|
493
|
+
|
494
|
+
only_headers = (source_files.count > 0 && @source_files.all? { |x| x.end_with?(".h") })
|
495
|
+
no_sources = (@source_files.count == 0 || only_headers) && (@vendored_frameworks + @vendored_libraries).count > 0
|
496
|
+
|
497
|
+
if !no_sources && !only_headers
|
498
|
+
return false
|
499
|
+
else
|
500
|
+
return (no_sources || only_headers || embedded_as_static_lib || embedded_as_vendored)
|
501
|
+
end
|
502
|
+
end
|
503
|
+
|
475
504
|
def extract_vendored_frameworks(spec, all_specs)
|
476
505
|
items = []
|
477
506
|
|
@@ -499,8 +528,12 @@ module PodBuilder
|
|
499
528
|
return items.flatten.uniq.compact
|
500
529
|
end
|
501
530
|
|
502
|
-
def extract_array(
|
503
|
-
|
531
|
+
def extract_array(dict, key)
|
532
|
+
if dict.nil?
|
533
|
+
return []
|
534
|
+
end
|
535
|
+
|
536
|
+
element = dict.fetch(key, [])
|
504
537
|
if element.instance_of? String
|
505
538
|
element = [element]
|
506
539
|
end
|