pod-builder 3.1.0 → 3.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f3d2e466990adefdd924214e92d94859aefc2d8b844722b87a602a53c8650a19
4
- data.tar.gz: 59511ec436382352ed7ca9d51ee1b60d72770a24297a27afd947514afc8f789e
3
+ metadata.gz: cf1ba531fbdf9edef61d09e7c1c0fe2c7822ba0823a64203895cc850d43f0288
4
+ data.tar.gz: 6d0101ec9a99a23b660cce491dffea35a66b9eb26820bb123bf704af5a67d196
5
5
  SHA512:
6
- metadata.gz: '09e89f2b8fefbc51d505f7205a9298e4298332b3442597c45d13da17efe74ee9099ded49613aa432e377d303f83e1a607735c07b16b9e3dfa91b52b556b9d43f'
7
- data.tar.gz: 6f6b831daa3db4d01feafdf73103098cf95f0c7ad3e058ec074ccf984b339605772fc799f45241a9fb6cac490499b86943e8f7f268ff43113f79276d9146ca88
6
+ metadata.gz: 94d82628002ce8f8debb7aadfd6f8ad8a928ee93bfe201a0ccd40fc21a063c912be4753890f5c13d9de765eed259634125caa425e9b804d894bac463bee2eb6e
7
+ data.tar.gz: af202cee868e1e52b30b2b4549a56f1dbcb568af028f2dd1ea026523168a50e0c11f72fb0d5a7b5daec524d8f6e91ca972562b9eb962bac63a329b1106c02e5b
data/README.md CHANGED
@@ -324,10 +324,26 @@ PodBuilder writes a plist and markdown license files of pods specified in the Po
324
324
 
325
325
  If you use bundler to pin the version of CocoaPods in your project set this to true. Default false.
326
326
 
327
+ #### `post_actions`
328
+
329
+ Post actions allow to execute custom scripts after a given command (`switch`, `build`) has been performed.
330
+
331
+ You need to specify a `path` to the executable script which is relative to the _PodBuilder_ folder. Optionally you can also specify whether the command should or should not print the output to stdout/stderr by passing a bool to the `quiet` key (default: false).
332
+
333
+ ```json
334
+ {
335
+ "post_actions": {
336
+ "switch" : { "path": "post_switch_action.rb", "quiet": true },
337
+ "build" : { "path": "post_buil_action.rb", "quiet": false }
338
+ }
339
+ }
340
+ ```
341
+
342
+
327
343
 
328
344
  # Behind the scenes
329
345
 
330
- PodBuilder leverages CocoaPods code and [cocoapods-rome plugin](https://github.com/CocoaPods/Prebuilt) to compile pods into frameworks. Every compiled framework will be boxed (by adding it as a `vendored_framework`) as a subspec of a local podspec. When needed additional settings will be automatically ported from the original podspec, like for example xcconfig settings.
346
+ PodBuilder leverages CocoaPods to compile pods into frameworks. Every compiled framework will be boxed (by adding it as a `vendored_framework`) as a subspec of a local podspec. When needed additional settings will be automatically ported from the original podspec, like for example custom xcconfig settings.
331
347
 
332
348
  # FAQ
333
349
 
@@ -17,19 +17,18 @@ module PodBuilder
17
17
  CLAide::Command::PluginManager.loaded_plugins["cocoapods"].push(pluginspec)
18
18
  end
19
19
 
20
- current_dir = Dir.pwd
21
- Dir.chdir(path)
22
-
23
- config = Pod::Config.new()
24
- installer = Pod::Installer.new(config.sandbox, config.podfile, config.lockfile)
25
- installer.repo_update = repo_update
26
- installer.update = false
27
-
28
- installer.prepare
29
-
30
- analyzer = installer.resolve_dependencies
31
-
32
- Dir.chdir(current_dir)
20
+ installer = nil
21
+ analyzer = nil
22
+ Dir.chdir(path) do
23
+ config = Pod::Config.new()
24
+ installer = Pod::Installer.new(config.sandbox, config.podfile, config.lockfile)
25
+ installer.repo_update = repo_update
26
+ installer.update = false
27
+
28
+ installer.prepare
29
+
30
+ analyzer = installer.resolve_dependencies
31
+ end
33
32
 
34
33
  return installer, analyzer
35
34
  end
@@ -147,6 +147,8 @@ module PodBuilder
147
147
  puts "\n\n⚠️ Podfile.restore was found invalid and was overwritten. Error:\n #{restore_file_error}".red
148
148
  end
149
149
 
150
+ Configuration.post_actions[:build]&.execute()
151
+
150
152
  puts "\n\n🎉 done!\n".green
151
153
  return 0
152
154
  end
@@ -154,7 +156,38 @@ module PodBuilder
154
156
  private
155
157
 
156
158
  def self.should_build_catalyst(installer)
157
- build_settings = installer.analysis_result.targets.map { |t| t.user_project.root_object.targets.map { |u| u.build_configuration_list.build_configurations.map { |v| v.build_settings } } }.flatten
159
+ integrate_targets = installer.podfile.installation_options.integrate_targets
160
+
161
+ # NOTE:
162
+ # When `integrate_targets` is false,
163
+ # `user_project` is nil and Build Settings cannot be collected,
164
+ # so collect Build Settings from xcodeproj and root xcodeproj defined in the Podfile
165
+ # ref:
166
+ # https://github.com/Subito-it/PodBuilder/issues/39
167
+ #
168
+ if integrate_targets
169
+ build_settings = installer.analysis_result.targets.map { |t| t.user_project.root_object.targets.map { |u| u.build_configuration_list.build_configurations.map { |v| v.build_settings } } }.flatten
170
+ else
171
+ # Find all `xcodeproj` in Podfile
172
+ user_projects_build_settings = installer.analysis_result.targets.map { |t|
173
+ user_project_path = PodBuilder.basepath + '/' + t.target_definition.user_project_path
174
+ project = Xcodeproj::Project.open(user_project_path)
175
+ project.root_object.targets.map { |u| u.build_configuration_list.build_configurations.map { |v| v.build_settings } }
176
+ }
177
+ .flatten
178
+ .compact
179
+
180
+ # Find root `xcodeproj`
181
+ project = Xcodeproj::Project.open(PodBuilder.find_xcodeproj)
182
+ root_project_build_setting = project
183
+ .root_object
184
+ .targets
185
+ .map { |u| u.build_configuration_list.build_configurations.map { |v| v.build_settings } }
186
+ .flatten
187
+
188
+ build_settings = user_projects_build_settings | root_project_build_setting
189
+ end
190
+
158
191
  build_catalyst = build_settings.detect { |t| t["SUPPORTS_MACCATALYST"] == "YES" } != nil
159
192
 
160
193
  puts "\nTo support Catalyst you should enable 'build_xcframeworks' in PodBuilder.json\n".red if build_catalyst && !Configuration.build_xcframeworks_all
@@ -43,15 +43,16 @@ module PodBuilder
43
43
 
44
44
  PodBuilder::safe_rm_rf(Configuration.base_path)
45
45
 
46
- Dir.chdir(PodBuilder::project_path)
47
- bundler_prefix = Configuration.use_bundler ? "bundle exec " : ""
48
- system("#{bundler_prefix}pod install;")
46
+ Dir.chdir(PodBuilder::project_path) do
47
+ bundler_prefix = Configuration.use_bundler ? "bundle exec " : ""
48
+ system("#{bundler_prefix}pod install;")
49
49
 
50
- license_base = PodBuilder::project_path(Configuration.license_filename)
51
- FileUtils.rm_f("#{license_base}.plist")
52
- FileUtils.rm_f("#{license_base}.md")
50
+ license_base = PodBuilder::project_path(Configuration.license_filename)
51
+ FileUtils.rm_f("#{license_base}.plist")
52
+ FileUtils.rm_f("#{license_base}.md")
53
53
 
54
- update_gemfile
54
+ update_gemfile
55
+ end
55
56
 
56
57
  puts "\n\n🎉 done!\n".green
57
58
  return 0
@@ -89,8 +90,9 @@ module PodBuilder
89
90
  gemfile_lines.select! { |x| !trim_gemfile_line(x).include?(trim_gemfile_line(podbuilder_line)) }
90
91
  File.write(gemfile_path, gemfile_lines.join("\n"))
91
92
 
92
- Dir.chdir(PodBuilder::home)
93
- system("bundle")
93
+ Dir.chdir(PodBuilder::home) do
94
+ system("bundle")
95
+ end
94
96
  end
95
97
 
96
98
  def self.trim_gemfile_line(line)
@@ -110,8 +110,9 @@ module PodBuilder
110
110
 
111
111
  File.write(gemfile_path, gemfile_lines.join("\n"))
112
112
 
113
- Dir.chdir(PodBuilder::home)
114
- system("bundle")
113
+ Dir.chdir(PodBuilder::home) do
114
+ system("bundle")
115
+ end
115
116
  end
116
117
 
117
118
  def self.trim_gemfile_line(line)
@@ -45,19 +45,17 @@ module PodBuilder
45
45
  dest_path = PodBuilder::basepath("Sources")
46
46
  FileUtils.mkdir_p(dest_path)
47
47
 
48
- current_dir = Dir.pwd
49
- Dir.chdir(dest_path)
50
-
51
- repo_dir = File.join(dest_path, spec.podspec_name)
52
- if !File.directory?(repo_dir)
53
- raise "\n\nFailed cloning #{spec.name}".red if !system("git clone #{spec.repo} #{spec.podspec_name}")
48
+ Dir.chdir(dest_path) do
49
+ repo_dir = File.join(dest_path, spec.podspec_name)
50
+ if !File.directory?(repo_dir)
51
+ raise "\n\nFailed cloning #{spec.name}".red if !system("git clone #{spec.repo} #{spec.podspec_name}")
52
+ end
54
53
  end
55
54
 
56
- Dir.chdir(repo_dir)
57
- puts "Checking out #{spec.podspec_name}".yellow
58
- raise "\n\nFailed cheking out #{spec.name}".red if !system(git_hard_checkout_cmd(spec))
59
-
60
- Dir.chdir(current_dir)
55
+ Dir.chdir(repo_dir) do
56
+ puts "Checking out #{spec.podspec_name}".yellow
57
+ raise "\n\nFailed cheking out #{spec.name}".red if !system(git_hard_checkout_cmd(spec))
58
+ end
61
59
  end
62
60
 
63
61
  def self.git_hard_checkout_cmd(spec)
@@ -195,9 +195,14 @@ module PodBuilder
195
195
  File.write(podfile_path, lines.join)
196
196
  end
197
197
 
198
- Dir.chdir(PodBuilder::project_path)
199
- bundler_prefix = Configuration.use_bundler ? "bundle exec " : ""
200
- system("#{bundler_prefix}pod install;")
198
+ Dir.chdir(PodBuilder::project_path) do
199
+ bundler_prefix = Configuration.use_bundler ? "bundle exec " : ""
200
+ system("#{bundler_prefix}pod install;")
201
+ end
202
+
203
+ Configuration.post_actions[:switch]&.execute()
204
+
205
+ puts "\n\n🎉 done!\n".green
201
206
 
202
207
  return 0
203
208
  end
@@ -218,11 +223,28 @@ module PodBuilder
218
223
  if Pathname.new(path).relative?
219
224
  path = PodBuilder::basepath(path)
220
225
  end
221
- podspec = Dir.glob(File.expand_path("#{path}/**/#{podname}*.podspec*"))
222
- podspec.select! { |x| !x.include?("/Local Podspecs/") }
223
- podspec.select! { |x| Dir.glob(File.join(File.dirname(x), "*")).count > 1 } # exclude podspec folder (which has one file per folder)
224
- if podspec.count > 0
225
- podspec_path = Pathname.new(podspec.first).dirname.to_s
226
+ podspec_paths = Dir.glob(File.expand_path("#{path}/**/#{podname}*.podspec*"))
227
+ podspec_paths.select! { |t| !t.include?("/Local Podspecs/") }
228
+ podspec_paths.select! { |t| Dir.glob(File.join(File.dirname(t), "*")).count > 1 } # exclude podspec folder (which has one file per folder)
229
+ if podspec_paths.count > 1
230
+ if match_name_path = podspec_paths.find{ |t| File.basename(t, ".*") == podname }
231
+ podspec_path = Pathname.new(match_name_path).dirname.to_s
232
+ else
233
+ # Try parsing podspec
234
+ podspec_paths.each do |path|
235
+ content = File.read(path).gsub("\"", "'").gsub(" ", "")
236
+ if content.include?("name='#{podname}'")
237
+ podspec_path = path
238
+ end
239
+ unless podspec_path.nil?
240
+ break
241
+ end
242
+ end
243
+ end
244
+
245
+ break
246
+ elsif podspec_paths.count == 1
247
+ podspec_path = Pathname.new(podspec_paths.first).dirname.to_s
226
248
  break
227
249
  end
228
250
  end
@@ -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
- previous_podfile_content = File.read("Podfile")
18
- Podfile::write_prebuilt(all_buildable_items, analyzer)
19
- updated_podfile_content = File.read("Podfile")
20
-
21
- Licenses::write([], all_buildable_items)
22
-
23
- if previous_podfile_content != updated_podfile_content
24
- bundler_prefix = Configuration.use_bundler ? "bundle exec " : ""
25
- system("#{bundler_prefix}pod install;")
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
 
@@ -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
 
@@ -424,6 +424,13 @@ module PodBuilder
424
424
  end
425
425
  end
426
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
+
427
434
  unless Dir.glob("#{source_path}/**/*").select { |t| File.file?(t) }.empty?
428
435
  destination_folder = PodBuilder::prebuiltpath(root_name)
429
436
  FileUtils.mkdir_p(destination_folder)
@@ -447,11 +454,9 @@ module PodBuilder
447
454
  end
448
455
 
449
456
  def self.init_git(path)
450
- current_dir = Dir.pwd
451
-
452
- Dir.chdir(path)
453
- system("git init")
454
- Dir.chdir(current_dir)
457
+ Dir.chdir(path) do
458
+ system("git init")
459
+ end
455
460
  end
456
461
 
457
462
  def self.build_folder_hash_in_prebuilt_info_file(podfile_item)
@@ -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
- build_settings[k] = v
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|
@@ -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(spec, key)
503
- element = spec.attributes_hash.fetch(key, [])
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
@@ -0,0 +1,46 @@
1
+ require 'pod_builder/core'
2
+ require 'json'
3
+
4
+ module PodBuilder
5
+ module PostActions
6
+ def self.load(hash)
7
+ actions = {}
8
+ if json = hash["switch"]
9
+ actions[:switch] = Item.new("switch", json)
10
+ end
11
+ if json = hash["build"]
12
+ actions[:build] = Item.new("build", json)
13
+ end
14
+
15
+ return actions
16
+ end
17
+
18
+ class Item
19
+ attr_reader :path
20
+ attr_reader :quiet
21
+ attr_reader :name
22
+
23
+ def initialize(name, hash)
24
+ @name = name
25
+ @path = hash.fetch("path", "")
26
+ @quiet = hash.fetch("quiet", false)
27
+
28
+ raise "\n\nEmpty or missing post #{name} action path\n".red if @path.empty?()
29
+ end
30
+
31
+ def execute()
32
+ cmd = PodBuilder::basepath(path)
33
+ unless File.exist?(cmd)
34
+ raise "\n\nPost #{name} action path '#{cmd}' does not exists!\n".red
35
+ end
36
+
37
+ if @quiet
38
+ cmd += " > /dev/null 2>&1"
39
+ end
40
+
41
+ puts "Executing post #{name} action".yellow
42
+ `#{cmd}`
43
+ end
44
+ end
45
+ end
46
+ end
@@ -1,4 +1,4 @@
1
1
  module PodBuilder
2
- VERSION = "3.1.0"
2
+ VERSION = "3.5.0"
3
3
  end
4
4
 
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: 3.1.0
4
+ version: 3.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomas Camin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-05-11 00:00:00.000000000 Z
11
+ date: 2021-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -208,6 +208,7 @@ files:
208
208
  - lib/pod_builder/podfile_cp.rb
209
209
  - lib/pod_builder/podfile_item.rb
210
210
  - lib/pod_builder/podspec.rb
211
+ - lib/pod_builder/post_actions.rb
211
212
  - lib/pod_builder/rome/post_install.rb
212
213
  - lib/pod_builder/rome/pre_install.rb
213
214
  - lib/pod_builder/templates/build_podfile.template