pod-builder 3.2.0 → 3.3.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: e0cdcd16503f8c363779e6b63a2a7c7ff66cc867a2092c65fb3a8bcb66758cfb
4
+ data.tar.gz: 199fc74359e90c198cac6e8c5c1ea1e172ae93ffe584ccccf5c8d324cda0f761
5
5
  SHA512:
6
- metadata.gz: 221ccda81fbd9b41d4439ebaa6a8ea3776e4c1d91ea3b24d268fa54203e67e757160ad0e42595527e0e610845ec1faf546aa9d480463f808aae28c94df4710e4
7
- data.tar.gz: ef65cce139a54a6ae93e5262e480a3608e9b268a51cf413da58e314d29568c6981f5b198dc1061d93d102ec112935dc890d7e5b009fabd0cc4cc88cce52e9650
6
+ metadata.gz: 42587bceee70997a3a91ab5428945e9e98094500ceafca8a7de957fb60784e9e2bc84d9f823fa7c00866c5910e651aa48ad7b200924163a1d9879df241fcd541
7
+ data.tar.gz: 60f520d51741fbff7d7216d018266182f4786a5b77c7eec21495d5199752edd850dbafaecd9644217d5bfb7643e41cce88d94b09c271372af2602846cd19db5a
data/README.md CHANGED
@@ -324,6 +324,22 @@ 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
 
@@ -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
@@ -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|
@@ -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.2.0"
2
+ VERSION = "3.3.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.2.0
4
+ version: 3.3.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-06-15 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