pod-builder 3.2.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '09cbb24dc2fb49946058f0459990c762afd54e93dfe280289203348162272611'
4
- data.tar.gz: 87fc03146c5a8a7fbe2adcc895e8a45c8b24b517b00c557236245902df543267
3
+ metadata.gz: f4eb5820c597538d2cdca26385c8d307d1ec1136d8c393594167fae25d1de240
4
+ data.tar.gz: 8a489a9710bc41a6c96ec3603227cb06e0a9d376835f05976c5e595bd45d902e
5
5
  SHA512:
6
- metadata.gz: 221ccda81fbd9b41d4439ebaa6a8ea3776e4c1d91ea3b24d268fa54203e67e757160ad0e42595527e0e610845ec1faf546aa9d480463f808aae28c94df4710e4
7
- data.tar.gz: ef65cce139a54a6ae93e5262e480a3608e9b268a51cf413da58e314d29568c6981f5b198dc1061d93d102ec112935dc890d7e5b009fabd0cc4cc88cce52e9650
6
+ metadata.gz: 3ed8a52ba842937a2a24626c55bd67932c9a2a2af80b8b3891dd00109597e42251e4eea694b4c4f5901218de22ec6b21ae95a87f5e9f034e4467c4d9e9c8c0b3
7
+ data.tar.gz: 00ac3c4c7c07716d84011dab03b5524e4154172bae3ecac9cce228b2b78047738c5037f057e0d14fb0e0779b29090f83b0b8df0c3e7f9f77a59369cf954db99c
data/README.md CHANGED
@@ -324,10 +324,45 @@ 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
+ #### `pre_actions`
328
+
329
+ Pre actions allow to execute custom scripts before 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
+ "pre_actions": {
336
+ "switch" : { "path": "pre_switch_action.rb", "quiet": true },
337
+ "build" : { "path": "pre_build_action.rb", "quiet": false }
338
+ }
339
+ }
340
+ ```
341
+
342
+ **Note:** The build action might be invoked more than once depending on the build strategy that PodBuilder needs to perform.
343
+
344
+
345
+ #### `post_actions`
346
+
347
+ Post actions allow to execute custom scripts after a given command (`switch`, `build`) has been performed.
348
+
349
+ 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).
350
+
351
+ ```json
352
+ {
353
+ "post_actions": {
354
+ "switch" : { "path": "post_switch_action.rb", "quiet": true },
355
+ "build" : { "path": "post_buil_action.rb", "quiet": false }
356
+ }
357
+ }
358
+ ```
359
+
360
+ **Note:** The build action might be invoked more than once depending on the build strategy that PodBuilder needs to perform.
361
+
327
362
 
328
363
  # Behind the scenes
329
364
 
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.
365
+ 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
366
 
332
367
  # FAQ
333
368
 
@@ -0,0 +1,46 @@
1
+ require 'pod_builder/core'
2
+ require 'json'
3
+
4
+ module PodBuilder
5
+ module Actions
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
@@ -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
@@ -114,10 +114,19 @@ module PodBuilder
114
114
  podfile_items = podfile_items.map { |t| t.recursive_dependencies(all_buildable_items) }.flatten.uniq
115
115
 
116
116
  podfile_content = Podfile.from_podfile_items(podfile_items, analyzer, build_configuration, install_using_frameworks, build_catalyst, podfile_items.first.build_xcframework)
117
+
118
+ PodBuilder::safe_rm_rf(Configuration.build_path)
119
+ FileUtils.mkdir_p(Configuration.build_path)
120
+
121
+ init_git(Configuration.build_path) # this is needed to be able to call safe_rm_rf
122
+
123
+ Configuration.pre_actions[:build]&.execute()
117
124
 
118
125
  install_result += Install.podfile(podfile_content, podfile_items, argument_pods, podfile_items.first.build_configuration)
119
126
 
120
127
  FileUtils.rm_f(PodBuilder::basepath("Podfile.lock"))
128
+
129
+ Configuration.post_actions[:build]&.execute()
121
130
  end
122
131
 
123
132
  install_result.write_prebuilt_info_files
@@ -145,7 +154,7 @@ module PodBuilder
145
154
 
146
155
  if (restore_file_error = restore_file_error) && Configuration.restore_enabled
147
156
  puts "\n\n⚠️ Podfile.restore was found invalid and was overwritten. Error:\n #{restore_file_error}".red
148
- end
157
+ end
149
158
 
150
159
  puts "\n\n🎉 done!\n".green
151
160
  return 0
@@ -153,8 +162,45 @@ module PodBuilder
153
162
 
154
163
  private
155
164
 
165
+ def self.init_git(path)
166
+ Dir.chdir(path) do
167
+ system("git init")
168
+ end
169
+ end
170
+
156
171
  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
172
+ integrate_targets = installer.podfile.installation_options.integrate_targets
173
+
174
+ # NOTE:
175
+ # When `integrate_targets` is false,
176
+ # `user_project` is nil and Build Settings cannot be collected,
177
+ # so collect Build Settings from xcodeproj and root xcodeproj defined in the Podfile
178
+ # ref:
179
+ # https://github.com/Subito-it/PodBuilder/issues/39
180
+ #
181
+ if integrate_targets
182
+ 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
183
+ else
184
+ # Find all `xcodeproj` in Podfile
185
+ user_projects_build_settings = installer.analysis_result.targets.map { |t|
186
+ user_project_path = PodBuilder.basepath + '/' + t.target_definition.user_project_path
187
+ project = Xcodeproj::Project.open(user_project_path)
188
+ project.root_object.targets.map { |u| u.build_configuration_list.build_configurations.map { |v| v.build_settings } }
189
+ }
190
+ .flatten
191
+ .compact
192
+
193
+ # Find root `xcodeproj`
194
+ project = Xcodeproj::Project.open(PodBuilder.find_xcodeproj)
195
+ root_project_build_setting = project
196
+ .root_object
197
+ .targets
198
+ .map { |u| u.build_configuration_list.build_configurations.map { |v| v.build_settings } }
199
+ .flatten
200
+
201
+ build_settings = user_projects_build_settings | root_project_build_setting
202
+ end
203
+
158
204
  build_catalyst = build_settings.detect { |t| t["SUPPORTS_MACCATALYST"] == "YES" } != nil
159
205
 
160
206
  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)
@@ -13,6 +13,8 @@ module PodBuilder
13
13
  return -1
14
14
  end
15
15
 
16
+ Configuration.pre_actions[:switch]&.execute()
17
+
16
18
  pods_not_found = []
17
19
  pod_names_to_switch = []
18
20
  argument_pods.each do |pod|
@@ -195,9 +197,14 @@ module PodBuilder
195
197
  File.write(podfile_path, lines.join)
196
198
  end
197
199
 
198
- Dir.chdir(PodBuilder::project_path)
199
- bundler_prefix = Configuration.use_bundler ? "bundle exec " : ""
200
- system("#{bundler_prefix}pod install;")
200
+ Dir.chdir(PodBuilder::project_path) do
201
+ bundler_prefix = Configuration.use_bundler ? "bundle exec " : ""
202
+ system("#{bundler_prefix}pod install;")
203
+ end
204
+
205
+ Configuration.post_actions[:switch]&.execute()
206
+
207
+ puts "\n\n🎉 done!\n".green
201
208
 
202
209
  return 0
203
210
  end
@@ -218,11 +225,28 @@ module PodBuilder
218
225
  if Pathname.new(path).relative?
219
226
  path = PodBuilder::basepath(path)
220
227
  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
228
+ podspec_paths = Dir.glob(File.expand_path("#{path}/**/#{podname}*.podspec*"))
229
+ podspec_paths.select! { |t| !t.include?("/Local Podspecs/") }
230
+ podspec_paths.select! { |t| Dir.glob(File.join(File.dirname(t), "*")).count > 1 } # exclude podspec folder (which has one file per folder)
231
+ if podspec_paths.count > 1
232
+ if match_name_path = podspec_paths.find{ |t| File.basename(t, ".*") == podname }
233
+ podspec_path = Pathname.new(match_name_path).dirname.to_s
234
+ else
235
+ # Try parsing podspec
236
+ podspec_paths.each do |path|
237
+ content = File.read(path).gsub("\"", "'").gsub(" ", "")
238
+ if content.include?("name='#{podname}'")
239
+ podspec_path = path
240
+ end
241
+ unless podspec_path.nil?
242
+ break
243
+ end
244
+ end
245
+ end
246
+
247
+ break
248
+ elsif podspec_paths.count == 1
249
+ podspec_path = Pathname.new(podspec_paths.first).dirname.to_s
226
250
  break
227
251
  end
228
252
  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,8 @@ 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 :pre_actions
79
+ attr_accessor :post_actions
78
80
  end
79
81
 
80
82
  @build_settings = DEFAULT_BUILD_SETTINGS
@@ -111,6 +113,9 @@ module PodBuilder
111
113
  @build_xcframeworks_all = false
112
114
  @build_xcframeworks_include = []
113
115
  @build_xcframeworks_exclude = []
116
+
117
+ @pre_actions = {}
118
+ @post_actions = {}
114
119
 
115
120
  def self.check_inited
116
121
  raise "\n\nNot inited, run `pod_builder init`\n".red if podbuilder_path.nil?
@@ -229,6 +234,16 @@ module PodBuilder
229
234
  Configuration.build_xcframeworks_exclude = value
230
235
  end
231
236
  end
237
+ if value = json["pre_actions"]
238
+ if value.is_a?(Hash)
239
+ Configuration.pre_actions = PodBuilder::Actions.load(value)
240
+ end
241
+ end
242
+ if value = json["post_actions"]
243
+ if value.is_a?(Hash)
244
+ Configuration.post_actions = PodBuilder::Actions.load(value)
245
+ end
246
+ end
232
247
 
233
248
  Configuration.build_settings.freeze
234
249
 
@@ -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/actions'
15
16
 
16
17
  require 'core_ext/string'
17
18
 
@@ -140,12 +140,7 @@ module PodBuilder
140
140
  class Install
141
141
  # This method will generate prebuilt data by building from "/tmp/pod_builder/Podfile"
142
142
  def self.podfile(podfile_content, podfile_items, argument_pods, build_configuration)
143
- puts "Preparing build Podfile".yellow
144
-
145
- PodBuilder::safe_rm_rf(Configuration.build_path)
146
- FileUtils.mkdir_p(Configuration.build_path)
147
-
148
- init_git(Configuration.build_path) # this is needed to be able to call safe_rm_rf
143
+ puts "Preparing build Podfile".yellow
149
144
 
150
145
  podfile_content = copy_development_pods_source_code(podfile_content, podfile_items)
151
146
 
@@ -424,6 +419,13 @@ module PodBuilder
424
419
  end
425
420
  end
426
421
 
422
+ # Cleanup unneeded files (see https://github.com/bazelbuild/rules_apple/pull/1113)
423
+ ignore_files = Dir.glob(["#{source_path}/**/Modules/**/*.swiftmodule/*.swiftdoc", "#{source_path}/**/Modules/**/*.swiftmodule/**/*.swiftsourceinfo"])
424
+ ignore_files.each { |t| PodBuilder::safe_rm_rf(t) }
425
+
426
+ project_folder = Dir.glob("#{source_path}/**/Modules/**/*.swiftmodule/Project")
427
+ project_folder.select { |t| File.directory?(t) && Dir.empty?(t) }.each { |t| PodBuilder::safe_rm_rf(t) }
428
+
427
429
  unless Dir.glob("#{source_path}/**/*").select { |t| File.file?(t) }.empty?
428
430
  destination_folder = PodBuilder::prebuiltpath(root_name)
429
431
  FileUtils.mkdir_p(destination_folder)
@@ -445,15 +447,7 @@ module PodBuilder
445
447
  File.write(gitattributes_path, expected_attributes, mode: 'a')
446
448
  end
447
449
  end
448
-
449
- def self.init_git(path)
450
- current_dir = Dir.pwd
451
-
452
- Dir.chdir(path)
453
- system("git init")
454
- Dir.chdir(current_dir)
455
- end
456
-
450
+
457
451
  def self.build_folder_hash_in_prebuilt_info_file(podfile_item)
458
452
  prebuilt_info_path = PodBuilder::prebuiltpath(File.join(podfile_item.root_name, Configuration.prebuilt_info_filename))
459
453
 
@@ -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|
@@ -585,8 +591,10 @@ module PodBuilder
585
591
  if matches&.size == 4 && !stripped_line.start_with?("#")
586
592
  path = matches[2]
587
593
 
594
+ file_exists = File.exist?(File.expand_path(path))
595
+
588
596
  is_absolute = ["~", "/"].include?(path[0])
589
- unless !is_absolute
597
+ if is_absolute || !file_exists
590
598
  podfile_lines.push(line)
591
599
  next
592
600
  end
@@ -184,14 +184,26 @@ module PodBuilder
184
184
  @weak_frameworks = []
185
185
  @libraries = []
186
186
 
187
- @frameworks += extract_array(spec, "framework")
188
- @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
189
193
 
190
- @weak_frameworks += extract_array(spec, "weak_framework")
191
- @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
192
200
 
193
- @libraries += extract_array(spec, "library")
194
- @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
195
207
 
196
208
  @header_dir = spec.attributes_hash["header_dir"]
197
209
 
@@ -201,7 +213,7 @@ module PodBuilder
201
213
  @swift_version = spec.root.swift_version&.to_s
202
214
  @module_name = spec.root.module_name
203
215
 
204
- @default_subspecs = extract_array(spec, "default_subspecs")
216
+ @default_subspecs = extract_array(spec.attributes_hash, "default_subspecs")
205
217
  if default_subspec = spec.attributes_hash["default_subspec"]
206
218
  @default_subspecs.push(default_subspec)
207
219
  end
@@ -516,8 +528,12 @@ module PodBuilder
516
528
  return items.flatten.uniq.compact
517
529
  end
518
530
 
519
- def extract_array(spec, key)
520
- 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, [])
521
537
  if element.instance_of? String
522
538
  element = [element]
523
539
  end
@@ -1,4 +1,3 @@
1
1
  module PodBuilder
2
- VERSION = "3.2.0"
2
+ VERSION = "4.0.0"
3
3
  end
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.2.0
4
+ version: 4.0.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-14 00:00:00.000000000 Z
11
+ date: 2021-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -181,6 +181,7 @@ files:
181
181
  - bin/setup
182
182
  - exe/pod_builder
183
183
  - lib/core_ext/string.rb
184
+ - lib/pod_builder/actions.rb
184
185
  - lib/pod_builder/analyze.rb
185
186
  - lib/pod_builder/analyzer.rb
186
187
  - lib/pod_builder/command.rb