pod-builder 5.1.1 → 5.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
- require 'fourflusher'
2
- require 'colored'
3
- require 'pathname'
1
+ require "fourflusher"
2
+ require "colored"
3
+ require "pathname"
4
4
 
5
5
  module PodBuilder
6
6
  class XcodeBuildSettings
@@ -11,7 +11,7 @@ module PodBuilder
11
11
  def initialize(platform_name, configuration)
12
12
  @platform_name = platform_name
13
13
  @configuration = configuration
14
-
14
+
15
15
  case platform_name
16
16
  when "iphoneos" then @build_destination = "generic/platform=iOS"
17
17
  when "iphonesimulator" then @build_destination = "generic/platform=iOS Simulator"
@@ -21,42 +21,43 @@ module PodBuilder
21
21
  when "tvossimulator" then @build_destination = "generic/platform=tvOS Simulator"
22
22
  when "watchos" then @build_destination = "generic/platform=watchOS"
23
23
  when "watchossimulator" then @build_destination = "generic/platform=watchOS Simulator"
24
- else raise "\n\nUnknown platform '#{platform_name}'\n".red end
24
+ else raise "\n\nUnknown platform '#{platform_name}'\n".red
25
+ end
25
26
  end
26
27
  end
27
28
 
28
- def self.build_for_iosish_platform_framework(sandbox, build_dir, target, device, simulator, configuration, deterministic_build)
29
+ def self.build_for_iosish_platform_framework(sandbox, build_dir, target, device, simulator, configuration, deterministic_build)
29
30
  dsym_device_folder = File.join(build_dir, "dSYM", device)
30
31
  dsym_simulator_folder = File.join(build_dir, "dSYM", simulator)
31
32
  FileUtils.mkdir_p(dsym_device_folder)
32
33
  FileUtils.mkdir_p(dsym_simulator_folder)
33
-
34
+
34
35
  deployment_target = target.platform_deployment_target
35
36
  target_label = target.cocoapods_target_label
36
-
37
+
37
38
  xcodebuild(sandbox, target_label, device, deployment_target, configuration, deterministic_build, [], {})
38
39
  excluded_archs = ["i386"] # Fixes https://github.com/Subito-it/PodBuilder/issues/17
39
40
  excluded_archs += ["arm64"] # Exclude apple silicon slice
40
41
  xcodebuild(sandbox, target_label, simulator, deployment_target, configuration, deterministic_build, excluded_archs, {})
41
-
42
+
42
43
  spec_names = target.specs.map { |spec| [spec.root.name, spec.root.module_name] }.uniq
43
44
  spec_names.each do |root_name, module_name|
44
- device_base = "#{build_dir}/#{configuration}-#{device}/#{root_name}"
45
+ device_base = "#{build_dir}/#{configuration}-#{device}/#{root_name}"
45
46
  device_lib = "#{device_base}/#{module_name}.framework/#{module_name}"
46
47
  device_dsym = "#{device_base}/#{module_name}.framework.dSYM"
47
48
  device_framework_lib = File.dirname(device_lib)
48
49
  device_swift_header_path = "#{device_framework_lib}/Headers/#{module_name}-Swift.h"
49
-
50
+
50
51
  simulator_base = "#{build_dir}/#{configuration}-#{simulator}/#{root_name}"
51
52
  simulator_lib = "#{simulator_base}/#{module_name}.framework/#{module_name}"
52
53
  simulator_dsym = "#{simulator_base}/#{module_name}.framework.dSYM"
53
54
  simulator_framework_lib = File.dirname(simulator_lib)
54
55
  simulator_swift_header_path = "#{simulator_framework_lib}/Headers/#{module_name}-Swift.h"
55
-
56
+
56
57
  next unless File.file?(device_lib) && File.file?(simulator_lib)
57
-
58
+
58
59
  # Starting with Xcode 12b3 the simulator binary contains an arm64 slice as well which conflict with the one in the device_lib
59
- # when creating the fat library. A naive workaround is to remove the arm64 from the simulator_lib however this is wrong because
60
+ # when creating the fat library. A naive workaround is to remove the arm64 from the simulator_lib however this is wrong because
60
61
  # we might actually need to have 2 separated arm64 slices, one for simulator and one for device each built with different
61
62
  # compile time directives (e.g #if targetEnvironment(simulator))
62
63
  #
@@ -64,50 +65,50 @@ module PodBuilder
64
65
  if `xcrun lipo -info #{simulator_lib}`.include?("arm64")
65
66
  `xcrun lipo -remove arm64 #{simulator_lib} -o #{simulator_lib}`
66
67
  end
67
-
68
+
68
69
  raise "\n\nLipo failed on #{device_lib}\n".red unless system("xcrun lipo -create -output #{device_lib} #{device_lib} #{simulator_lib}")
69
-
70
+
70
71
  merge_header_into(device_swift_header_path, simulator_swift_header_path)
71
-
72
- # Merge device framework into simulator framework (so that e.g swift Module folder is merged)
72
+
73
+ # Merge device framework into simulator framework (so that e.g swift Module folder is merged)
73
74
  # letting device framework files overwrite simulator ones
74
- FileUtils.cp_r(File.join(device_framework_lib, "."), simulator_framework_lib)
75
+ FileUtils.cp_r(File.join(device_framework_lib, "."), simulator_framework_lib)
75
76
  source_lib = File.dirname(simulator_framework_lib)
76
-
77
+
77
78
  FileUtils.mv(device_dsym, dsym_device_folder) if File.exist?(device_dsym)
78
79
  FileUtils.mv(simulator_dsym, dsym_simulator_folder) if File.exist?(simulator_dsym)
79
-
80
+
80
81
  FileUtils.mv(source_lib, build_dir)
81
-
82
+
82
83
  # Remove frameworks leaving dSYMs
83
- FileUtils.rm_rf(device_framework_lib)
84
+ FileUtils.rm_rf(device_framework_lib)
84
85
  FileUtils.rm_rf(simulator_framework_lib)
85
86
  end
86
87
  end
87
-
88
- def self.build_for_iosish_platform_lib(sandbox, build_dir, target, device, simulator, configuration, deterministic_build, prebuilt_root_paths)
88
+
89
+ def self.build_for_iosish_platform_lib(sandbox, build_dir, target, device, simulator, configuration, deterministic_build, prebuilt_root_paths)
89
90
  deployment_target = target.platform_deployment_target
90
91
  target_label = target.cocoapods_target_label
91
-
92
+
92
93
  spec_names = target.specs.map { |spec| [spec.root.name, spec.root.module_name] }.uniq
93
-
94
+
94
95
  xcodebuild(sandbox, target_label, device, deployment_target, configuration, deterministic_build, [], prebuilt_root_paths)
95
96
  excluded_archs = ["arm64"] # Exclude Apple silicon slice
96
97
  xcodebuild(sandbox, target_label, simulator, deployment_target, configuration, deterministic_build, excluded_archs, prebuilt_root_paths)
97
-
98
+
98
99
  spec_names.each do |root_name, module_name|
99
100
  simulator_base = "#{build_dir}/#{configuration}-#{simulator}/#{root_name}"
100
101
  simulator_lib = "#{simulator_base}/lib#{root_name}.a"
101
-
102
- device_base = "#{build_dir}/#{configuration}-#{device}/#{root_name}"
102
+
103
+ device_base = "#{build_dir}/#{configuration}-#{device}/#{root_name}"
103
104
  device_lib = "#{device_base}/lib#{root_name}.a"
104
-
105
+
105
106
  unless File.file?(device_lib) && File.file?(simulator_lib)
106
107
  next
107
108
  end
108
-
109
+
109
110
  # Starting with Xcode 12b3 the simulator binary contains an arm64 slice as well which conflict with the one in the device_lib
110
- # when creating the fat library. A naive workaround is to remove the arm64 from the simulator_lib however this is wrong because
111
+ # when creating the fat library. A naive workaround is to remove the arm64 from the simulator_lib however this is wrong because
111
112
  # we might actually need to have 2 separated arm64 slices, one for simulator and one for device each built with different
112
113
  # compile time directives (e.g #if targetEnvironment(simulator))
113
114
  #
@@ -115,16 +116,16 @@ module PodBuilder
115
116
  if `xcrun lipo -info #{simulator_lib}`.include?("arm64")
116
117
  `xcrun lipo -remove arm64 #{simulator_lib} -o #{simulator_lib}`
117
118
  end
118
-
119
+
119
120
  raise "\n\nLipo failed on #{device_lib}\n".red unless system("xcrun lipo -create -output #{device_lib} #{device_lib} #{simulator_lib}")
120
-
121
+
121
122
  device_headers = Dir.glob("#{device_base}/**/*.h")
122
123
  simulator_headers = Dir.glob("#{simulator_base}/**/*.h")
123
124
  device_headers.each do |device_path|
124
125
  simulator_path = device_path.gsub(device_base, simulator_base)
125
-
126
+
126
127
  merge_header_into(device_path, simulator_path)
127
- end
128
+ end
128
129
  simulator_only_headers = simulator_headers - device_headers.map { |t| t.gsub(device_base, simulator_base) }
129
130
  simulator_only_headers.each do |path|
130
131
  add_simulator_conditional(path)
@@ -133,21 +134,21 @@ module PodBuilder
133
134
  FileUtils.mkdir_p(destination_folder)
134
135
  FileUtils.cp(path, destination_folder)
135
136
  end
136
-
137
+
137
138
  swiftmodule_path = "#{simulator_base}/#{root_name}.swiftmodule"
138
139
  if File.directory?(swiftmodule_path)
139
140
  FileUtils.cp_r("#{swiftmodule_path}/.", "#{device_base}/#{root_name}.swiftmodule")
140
141
  end
141
-
142
+
142
143
  if File.exist?("#{device_base}/#{root_name}.swiftmodule")
143
144
  # This is a swift pod with a swiftmodule in the root of the prebuilt folder
144
145
  else
145
146
  # Objective-C pods have the swiftmodule generated under Pods/Headers/Public
146
147
  public_headers_path = "#{Configuration.build_path}/Pods/Headers/Public/#{root_name}"
147
- module_public_headers_path = "#{Configuration.build_path}/Pods/Headers/Public/#{module_name}"
148
+ module_public_headers_path = "#{Configuration.build_path}/Pods/Headers/Public/#{module_name}"
148
149
  if public_headers_path.downcase != module_public_headers_path.downcase && File.directory?(public_headers_path) && File.directory?(module_public_headers_path)
149
150
  # For pods with module_name != name we have to move the modulemap files to the root_name one
150
- module_public_headers_path = "#{Configuration.build_path}/Pods/Headers/Public/#{module_name}"
151
+ module_public_headers_path = "#{Configuration.build_path}/Pods/Headers/Public/#{module_name}"
151
152
  FileUtils.cp_r("#{module_public_headers_path}/.", public_headers_path, :remove_destination => true)
152
153
  end
153
154
  Dir.glob("#{public_headers_path}/**/*.*").each do |path|
@@ -155,29 +156,29 @@ module PodBuilder
155
156
  destination_folder = File.dirname(destination_folder)
156
157
  FileUtils.mkdir_p(destination_folder)
157
158
  FileUtils.cp(path, destination_folder)
158
- end
159
+ end
159
160
  end
160
-
161
+
161
162
  destination_path = "#{build_dir}/#{root_name}"
162
163
  if Dir.glob("#{device_base}/**/*.{a,framework,h}").count > 0
163
164
  FileUtils.mv(device_base, destination_path)
164
-
165
+
165
166
  module_maps = Dir.glob("#{destination_path}/**/*.modulemap")
166
167
  module_map_device_base = device_base.gsub(/^\/private/, "") + "/"
167
168
  module_maps.each do |module_map|
168
169
  content = File.read(module_map)
169
170
  content.gsub!(module_map_device_base, "")
170
171
  File.write(module_map, content)
171
- end
172
+ end
172
173
  end
173
174
  end
174
175
  end
175
-
176
+
176
177
  def self.merge_header_into(device_file, simulator_file)
177
178
  unless File.exist?(device_file) || File.exist?(simulator_file)
178
179
  return
179
180
  end
180
-
181
+
181
182
  device_content = File.file?(device_file) ? File.read(device_file) : ""
182
183
  simulator_content = File.file?(simulator_file) ? File.read(simulator_file) : ""
183
184
  merged_content = %{
@@ -194,27 +195,27 @@ module PodBuilder
194
195
 
195
196
  // ->
196
197
  #endif
197
- }
198
+ }
198
199
  File.write(device_file, merged_content)
199
- end
200
-
200
+ end
201
+
201
202
  def self.add_simulator_conditional(path)
202
203
  file_content = File.read(path)
203
204
  content = %{
204
205
  #if TARGET_OS_SIMULATOR
205
206
  #{file_content}
206
207
  #endif
207
- }
208
+ }
208
209
  File.write(path, content)
209
210
  end
210
-
211
- def self.xcodebuild(sandbox, target, sdk='macosx', deployment_target=nil, configuration, deterministic_build, exclude_archs, prebuilt_root_paths)
211
+
212
+ def self.xcodebuild(sandbox, target, sdk = "macosx", deployment_target = nil, configuration, deterministic_build, exclude_archs, prebuilt_root_paths)
212
213
  args = %W(-project #{sandbox.project_path.realdirpath} -scheme #{target} -configuration #{configuration} -sdk #{sdk})
213
- supported_platforms = { 'iphonesimulator' => 'iOS', 'appletvsimulator' => 'tvOS', 'watchsimulator' => 'watchOS' }
214
+ supported_platforms = { "iphonesimulator" => "iOS", "appletvsimulator" => "tvOS", "watchsimulator" => "watchOS" }
214
215
  if platform = supported_platforms[sdk]
215
216
  args += Fourflusher::SimControl.new.destination(:oldest, platform, deployment_target) unless platform.nil?
216
217
  end
217
-
218
+
218
219
  xcodebuild_version = `xcodebuild -version | head -n1 | awk '{print $2}'`.strip().to_f
219
220
  if exclude_archs.count > 0 && xcodebuild_version >= 12.0
220
221
  args += ["EXCLUDED_ARCHS=#{exclude_archs.join(" ")}"]
@@ -222,25 +223,25 @@ module PodBuilder
222
223
  prebuilt_root_paths.each do |k, v|
223
224
  args += ["#{k.upcase.gsub("-", "_")}_PREBUILT_ROOT=#{v.gsub(/ /, '\ ')}"]
224
225
  end
225
-
226
+
226
227
  environmental_variables = {}
227
228
  if deterministic_build
228
229
  environmental_variables["ZERO_AR_DATE"] = "1"
229
230
  end
230
-
231
- execute_command 'xcodebuild', args, true, environmental_variables
231
+
232
+ execute_command "xcodebuild", args, true, environmental_variables
232
233
  end
233
-
234
+
234
235
  # Copy paste implementation from CocoaPods internals to be able to call poopen3 passing environmental variables
235
236
  def self.execute_command(executable, command, raise_on_failure = true, environmental_variables = {})
236
237
  bin = Pod::Executable.which!(executable)
237
-
238
+
238
239
  command = command.map(&:to_s)
239
- full_command = "#{bin} #{command.join(' ')}"
240
-
240
+ full_command = "#{bin} #{command.join(" ")}"
241
+
241
242
  stdout = Pod::Executable::Indenter.new
242
243
  stderr = Pod::Executable::Indenter.new
243
-
244
+
244
245
  status = popen3(bin, command, stdout, stderr, environmental_variables)
245
246
  stdout = stdout.join
246
247
  stderr = stderr.join
@@ -252,27 +253,27 @@ module PodBuilder
252
253
  UI.message("[!] Failed: #{full_command}".red)
253
254
  end
254
255
  end
255
-
256
+
256
257
  output
257
258
  end
258
-
259
+
259
260
  def self.popen3(bin, command, stdout, stderr, environmental_variables)
260
- require 'open3'
261
+ require "open3"
261
262
  Open3.popen3(environmental_variables, bin, *command) do |i, o, e, t|
262
263
  Pod::Executable::reader(o, stdout)
263
264
  Pod::Executable::reader(e, stderr)
264
265
  i.close
265
-
266
+
266
267
  status = t.value
267
-
268
+
268
269
  o.flush
269
270
  e.flush
270
271
  sleep(0.01)
271
-
272
+
272
273
  status
273
274
  end
274
275
  end
275
-
276
+
276
277
  def self.enable_debug_information(project_path, configuration)
277
278
  project = Xcodeproj::Project.open(project_path)
278
279
  project.targets.each do |target|
@@ -288,49 +289,50 @@ def self.copy_resources_and_vendored_items(installer_context, uses_frameworks, b
288
289
  installer_context.umbrella_targets.each do |umbrella|
289
290
  umbrella.specs.each do |spec|
290
291
  root_name = spec.name.split("/").first
291
-
292
+
292
293
  if uses_frameworks
293
- destination = File.join(base_destination, root_name)
294
+ destination = File.join(base_destination, root_name)
294
295
  else
295
- destination = File.join(base_destination, root_name, root_name)
296
+ destination = File.join(base_destination, root_name, root_name)
296
297
  end
297
298
  # Make sure the device target overwrites anything in the simulator build, otherwise iTunesConnect
298
299
  # can get upset about Info.plist containing references to the simulator SDK
299
300
  files = Pathname.glob("build/#{root_name}/*").reject { |f| f.to_s =~ /Pods[^.]+\.framework/ }
300
-
301
+
301
302
  consumer = spec.consumer(umbrella.platform_name)
302
303
  file_accessor = Pod::Sandbox::FileAccessor.new(sandbox.pod_dir(spec.root.name), consumer)
303
304
  files += file_accessor.vendored_libraries
304
305
  files += file_accessor.vendored_frameworks
305
306
  files += file_accessor.resources
306
-
307
- FileUtils.mkdir_p(destination)
307
+
308
+ FileUtils.mkdir_p(destination)
308
309
  files.each do |file|
309
310
  FileUtils.cp_r(file, destination)
310
- end
311
+ end
311
312
  end
312
313
  end
313
314
  end
314
315
 
315
- Pod::HooksManager.register('podbuilder-rome', :post_install) do |installer_context, user_options|
316
- enable_dsym = user_options.fetch('dsym', true)
317
- configuration = user_options.fetch('configuration', 'Debug')
318
- uses_frameworks = user_options.fetch('uses_frameworks', true)
316
+ Pod::HooksManager.register("podbuilder-rome", :post_install) do |installer_context, user_options|
317
+ enable_dsym = user_options.fetch("dsym", true)
318
+ configuration = user_options.fetch("configuration", "Debug")
319
+ uses_frameworks = user_options.fetch("uses_frameworks", true)
319
320
  if user_options["pre_compile"]
320
321
  user_options["pre_compile"].call(installer_context)
321
322
  end
322
- build_catalyst = user_options.fetch('build_catalyst', false)
323
- build_xcframeworks = user_options.fetch('build_xcframeworks', false)
324
-
325
- prebuilt_root_paths = JSON.parse(user_options["prebuilt_root_paths"].gsub('=>', ':'))
326
-
323
+ build_catalyst = user_options.fetch("build_catalyst", false)
324
+ build_xcframeworks = user_options.fetch("build_xcframeworks", false)
325
+ keep_swiftmodules = user_options.fetch("keep_swiftmodules", false)
326
+
327
+ prebuilt_root_paths = JSON.parse(user_options["prebuilt_root_paths"].gsub("=>", ":"))
328
+
327
329
  sandbox_root = Pathname(installer_context.sandbox_root)
328
330
  sandbox = Pod::Sandbox.new(sandbox_root)
329
-
331
+
330
332
  PodBuilder::enable_debug_information(sandbox.project_path, configuration)
331
-
332
- build_dir = sandbox_root.parent + 'build'
333
- base_destination = sandbox_root.parent + 'Prebuilt'
333
+
334
+ build_dir = sandbox_root.parent + "build"
335
+ base_destination = sandbox_root.parent + "Prebuilt"
334
336
 
335
337
  build_dir.rmtree if build_dir.directory?
336
338
  base_destination.rmtree if base_destination.directory?
@@ -340,10 +342,10 @@ Pod::HooksManager.register('podbuilder-rome', :post_install) do |installer_conte
340
342
  target = targets.first
341
343
 
342
344
  if build_xcframeworks
343
- project_path = sandbox_root.parent + 'Pods/Pods.xcodeproj'
344
-
345
+ project_path = sandbox_root.parent + "Pods/Pods.xcodeproj"
346
+
345
347
  case target.platform_name
346
- when :ios then
348
+ when :ios
347
349
  xcodebuild_settings = [PodBuilder::XcodeBuildSettings.new("iphoneos", configuration), PodBuilder::XcodeBuildSettings.new("iphonesimulator", configuration)]
348
350
  if build_catalyst
349
351
  xcodebuild_settings += [PodBuilder::XcodeBuildSettings.new("catalyst", configuration)]
@@ -351,17 +353,29 @@ Pod::HooksManager.register('podbuilder-rome', :post_install) do |installer_conte
351
353
  when :osx then xcodebuild_settings = [PodBuilder::XcodeBuildSettings.new("macos", configuration)]
352
354
  when :tvos then xcodebuild_settings = [PodBuilder::XcodeBuildSettings.new("tvos", configuration), PodBuilder::XcodeBuildSettings.new("tvossimulator", configuration)]
353
355
  when :watchos then xcodebuild_settings = [PodBuilder::XcodeBuildSettings.new("watchos", configuration), PodBuilder::XcodeBuildSettings.new("watchossimulator", configuration)]
354
- else raise "\n\nUnknown platform '#{target.platform_name}'\n".red end
355
-
356
+ else raise "\n\nUnknown platform '#{target.platform_name}'\n".red
357
+ end
358
+
356
359
  xcodebuild_settings.each do |xcodebuild_setting|
357
360
  puts "Building xcframeworks for #{xcodebuild_setting.platform_name}".yellow
358
- raise "\n\n#{xcodebuild_setting.build_destination} xcframework archive failed!\n".red if !system("xcodebuild archive -project #{project_path.to_s} -scheme Pods-DummyTarget -configuration #{xcodebuild_setting.configuration} -destination '#{xcodebuild_setting.build_destination}' -archivePath '#{build_dir}/#{xcodebuild_setting.platform_name}' SKIP_INSTALL=NO > /dev/null 2>&1")
361
+
362
+ log_path = "#{PodBuilder::Configuration.build_base_path}/archive_#{xcodebuild_setting.platform_name}.log"
363
+ archive_cmd = "xcodebuild archive -project #{project_path.to_s} -scheme Pods-DummyTarget -configuration #{xcodebuild_setting.configuration} -destination '#{xcodebuild_setting.build_destination}' -archivePath '#{build_dir}/#{xcodebuild_setting.platform_name}' SKIP_INSTALL=NO > #{log_path}"
364
+ unless system(archive_cmd)
365
+ puts "\n\n#{xcodebuild_setting.build_destination} xcframework archive failed, see #{log_path}!\n".red
366
+ if system("which xcbeautify")
367
+ puts `cat '#{log_path}' | xcbeautify --is-ci`
368
+ elsif system("which xcpretty")
369
+ puts `cat '#{log_path}' | xcpretty`
370
+ end
371
+ raise ""
372
+ end
359
373
  end
360
374
 
361
375
  built_items = Dir.glob("#{build_dir}/#{xcodebuild_settings[0].platform_name}.xcarchive/Products/Library/Frameworks/*").reject { |t| File.basename(t, ".*") == "Pods_DummyTarget" }
362
376
 
363
377
  specs = installer_context.umbrella_targets.map(&:specs).flatten
364
- built_items.each do |built_item|
378
+ built_items.each do |built_item|
365
379
  built_item_paths = [built_item]
366
380
  xcodebuild_settings.drop(1).each do |xcodebuild_setting|
367
381
  path = "#{build_dir}/#{xcodebuild_setting.platform_name}.xcarchive/Products/Library/Frameworks/#{File.basename(built_item)}"
@@ -388,8 +402,25 @@ Pod::HooksManager.register('podbuilder-rome', :post_install) do |installer_conte
388
402
 
389
403
  root_name = spec.name.split("/").first
390
404
  xcframework_path = "#{base_destination}/#{root_name}/#{module_name}.xcframework"
391
- framework_params = built_item_paths.map { |t| "-framework '#{t}'"}.join(" ")
392
- raise "\n\nFailed packing xcframework!\n".red if !system("xcodebuild -create-xcframework #{framework_params} -output '#{xcframework_path}' > /dev/null 2>&1")
405
+ framework_params = built_item_paths.map { |t| "-framework '#{t}'" }.join(" ")
406
+
407
+ log_path = "#{PodBuilder::Configuration.build_base_path}/create_framework.log"
408
+ create_framework_cmd = "xcodebuild -create-xcframework #{framework_params} -output '#{xcframework_path}' > #{log_path}"
409
+ raise "\n\nFailed packing xcframework! See #{log_path}\n".red if !system(create_framework_cmd)
410
+
411
+ if keep_swiftmodules
412
+ # At cost of losing ABI stability we restore .swiftmodule files that are removed by xcodebuild to improve build times
413
+ swiftinterfaces = Dir.glob("#{xcframework_path}/**/*.swiftinterface").reject { |t| t.include?("private.swiftinterface") }
414
+ swiftmodules = Dir.glob("#{build_dir}/**/#{module_name}.framework/**/*.swiftmodule").select { |t| File.file?(t) }
415
+
416
+ swiftinterfaces.each do |path|
417
+ expected_swiftmodule_name = File.basename(path, ".*")
418
+ if swiftmodule_path = swiftmodules.detect { |t| File.basename(t, ".*") == expected_swiftmodule_name }
419
+ destination_path = File.dirname(path)
420
+ FileUtils.cp(swiftmodule_path, destination_path)
421
+ end
422
+ end
423
+ end
393
424
 
394
425
  if enable_dsym
395
426
  xcodebuild_settings.each do |xcodebuild_setting|
@@ -399,7 +430,7 @@ Pod::HooksManager.register('podbuilder-rome', :post_install) do |installer_conte
399
430
  FileUtils.mkdir_p(destination)
400
431
  FileUtils.mv(dsym_source, destination)
401
432
  FileUtils.mv("#{destination}/dSYMs", "#{destination}/#{xcodebuild_setting.platform_name}")
402
- end
433
+ end
403
434
  end
404
435
  else
405
436
  raise "\n\nNot implemented\n".red
@@ -407,38 +438,39 @@ Pod::HooksManager.register('podbuilder-rome', :post_install) do |installer_conte
407
438
  end
408
439
 
409
440
  built_count = built_items.count
410
- Pod::UI.puts "Built #{built_count} #{'item'.pluralize(built_count)}"
441
+ Pod::UI.puts "Built #{built_count} #{"item".pluralize(built_count)}"
411
442
 
412
443
  copy_resources_and_vendored_items(installer_context, true, base_destination, sandbox)
413
444
  else
414
445
  case [target.platform_name, uses_frameworks]
415
- when [:ios, true] then PodBuilder::build_for_iosish_platform_framework(sandbox, build_dir, target, 'iphoneos', 'iphonesimulator', configuration, PodBuilder::Configuration.deterministic_build)
446
+ when [:ios, true] then PodBuilder::build_for_iosish_platform_framework(sandbox, build_dir, target, "iphoneos", "iphonesimulator", configuration, PodBuilder::Configuration.deterministic_build)
416
447
  when [:osx, true] then PodBuilder::xcodebuild(sandbox, target.cocoapods_target_label, configuration, PodBuilder::Configuration.deterministic_build, {})
417
- when [:tvos, true] then PodBuilder::build_for_iosish_platform_framework(sandbox, build_dir, target, 'appletvos', 'appletvsimulator', configuration, PodBuilder::Configuration.deterministic_build)
418
- when [:watchos, true] then PodBuilder::build_for_iosish_platform_framework(sandbox, build_dir, target, 'watchos', 'watchsimulator', configuration, PodBuilder::Configuration.deterministic_build)
419
- when [:ios, false] then PodBuilder::build_for_iosish_platform_lib(sandbox, build_dir, target, 'iphoneos', 'iphonesimulator', configuration, PodBuilder::Configuration.deterministic_build, prebuilt_root_paths)
448
+ when [:tvos, true] then PodBuilder::build_for_iosish_platform_framework(sandbox, build_dir, target, "appletvos", "appletvsimulator", configuration, PodBuilder::Configuration.deterministic_build)
449
+ when [:watchos, true] then PodBuilder::build_for_iosish_platform_framework(sandbox, build_dir, target, "watchos", "watchsimulator", configuration, PodBuilder::Configuration.deterministic_build)
450
+ when [:ios, false] then PodBuilder::build_for_iosish_platform_lib(sandbox, build_dir, target, "iphoneos", "iphonesimulator", configuration, PodBuilder::Configuration.deterministic_build, prebuilt_root_paths)
420
451
  when [:osx, false] then PodBuilder::xcodebuild(sandbox, target.cocoapods_target_label, configuration, PodBuilder::Configuration.deterministic_build, prebuilt_root_paths)
421
- when [:tvos, false] then PodBuilder::build_for_iosish_platform_lib(sandbox, build_dir, target, 'appletvos', 'appletvsimulator', configuration, PodBuilder::Configuration.deterministic_build, prebuilt_root_paths)
422
- when [:watchos, false] then PodBuilder::build_for_iosish_platform_lib(sandbox, build_dir, target, 'watchos', 'watchsimulator', configuration, PodBuilder::Configuration.deterministic_build, prebuilt_root_paths)
423
- else raise "\n\nUnknown platform '#{target.platform_name}'\n".red end
452
+ when [:tvos, false] then PodBuilder::build_for_iosish_platform_lib(sandbox, build_dir, target, "appletvos", "appletvsimulator", configuration, PodBuilder::Configuration.deterministic_build, prebuilt_root_paths)
453
+ when [:watchos, false] then PodBuilder::build_for_iosish_platform_lib(sandbox, build_dir, target, "watchos", "watchsimulator", configuration, PodBuilder::Configuration.deterministic_build, prebuilt_root_paths)
454
+ else raise "\n\nUnknown platform '#{target.platform_name}'\n".red
455
+ end
456
+
457
+ raise Pod::Informative, "The build directory was not found in the expected location." unless build_dir.directory?
424
458
 
425
- raise Pod::Informative, 'The build directory was not found in the expected location.' unless build_dir.directory?
426
-
427
459
  specs = installer_context.umbrella_targets.map { |t| t.specs.map(&:name) }.flatten.map { |t| t.split("/").first }.uniq
428
460
  built_count = Dir["#{build_dir}/*"].select { |t| specs.include?(File.basename(t)) }.count
429
- Pod::UI.puts "Built #{built_count} #{'item'.pluralize(built_count)}, copying..."
430
-
461
+ Pod::UI.puts "Built #{built_count} #{"item".pluralize(built_count)}, copying..."
462
+
431
463
  copy_resources_and_vendored_items(installer_context, uses_frameworks, base_destination, sandbox)
432
-
464
+
433
465
  # Depending on the resource it may happen that it is present twice, both in the .framework and in the parent folder
434
466
  Dir.glob("#{base_destination}/*") do |path|
435
467
  unless File.directory?(path)
436
468
  return
437
469
  end
438
-
470
+
439
471
  files = Dir.glob("#{path}/*")
440
472
  framework_files = Dir.glob("#{path}/*.framework/**/*").map { |t| File.basename(t) }
441
-
473
+
442
474
  files.each do |file|
443
475
  filename = File.basename(file.gsub(/\.xib$/, ".nib"))
444
476
  if framework_files.include?(filename)
@@ -446,7 +478,7 @@ Pod::HooksManager.register('podbuilder-rome', :post_install) do |installer_conte
446
478
  end
447
479
  end
448
480
  end
449
-
481
+
450
482
  if enable_dsym
451
483
  dsym_source = "#{build_dir}/dSYM"
452
484
  if File.directory?(dsym_source)
@@ -454,12 +486,12 @@ Pod::HooksManager.register('podbuilder-rome', :post_install) do |installer_conte
454
486
  end
455
487
  else
456
488
  raise "\n\nNot implemented\n".red
457
- end
489
+ end
458
490
  end
459
491
 
460
492
  build_dir.rmtree if build_dir.directory?
461
-
493
+
462
494
  if user_options["post_compile"]
463
495
  user_options["post_compile"].call(installer_context)
464
496
  end
465
- end
497
+ end
@@ -7,7 +7,7 @@ PodBuilder::Configuration::load
7
7
 
8
8
  %%%use_frameworks%%%
9
9
 
10
- plugin 'podbuilder-rome', { dsym: true, configuration: '%%%build_configuration%%%', uses_frameworks: %%%uses_frameworks%%%, build_catalyst: %%%build_catalyst%%%, build_xcframeworks: %%%build_xcframeworks%%%, prebuilt_root_paths: '%%%prebuilt_root_paths%%%', pre_compile: Proc.new { |installer|
10
+ plugin 'podbuilder-rome', { dsym: true, configuration: '%%%build_configuration%%%', uses_frameworks: %%%uses_frameworks%%%, keep_swiftmodules: %%%keep_swiftmodules%%%, build_catalyst: %%%build_catalyst%%%, build_xcframeworks: %%%build_xcframeworks%%%, prebuilt_root_paths: '%%%prebuilt_root_paths%%%', pre_compile: Proc.new { |installer|
11
11
 
12
12
  def set_build_settings(target_name, build_configurations, installer)
13
13
  installer.pods_project.targets.each do |target|
@@ -1,3 +1,3 @@
1
1
  module PodBuilder
2
- VERSION = "5.1.1"
2
+ VERSION = "5.1.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pod-builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.1.1
4
+ version: 5.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomas Camin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-12-20 00:00:00.000000000 Z
11
+ date: 2023-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -187,6 +187,7 @@ files:
187
187
  - lib/pod_builder/command.rb
188
188
  - lib/pod_builder/command/build.rb
189
189
  - lib/pod_builder/command/build_all.rb
190
+ - lib/pod_builder/command/build_swiftmodules.rb
190
191
  - lib/pod_builder/command/clean.rb
191
192
  - lib/pod_builder/command/deintegrate.rb
192
193
  - lib/pod_builder/command/generate_lldbinit.rb