pod-builder 3.0.1 → 3.1.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: f6e1128204135a976e3e6f670dd87d43cf860c762c953ceb0b892af38a799f6a
4
- data.tar.gz: cae42cf415e9d728048ab8d4fbcdf615e53511558f955bc6128dd12fc107beb4
3
+ metadata.gz: f3d2e466990adefdd924214e92d94859aefc2d8b844722b87a602a53c8650a19
4
+ data.tar.gz: 59511ec436382352ed7ca9d51ee1b60d72770a24297a27afd947514afc8f789e
5
5
  SHA512:
6
- metadata.gz: 2550ca69349e42b85a7ff16d72d568b9e8c0bd15a2cf301fc6bf0494d27eba3c78aa44be9ef0c062b0a67344dfa27c2ae03b910272a82cc546e7c5ce432f3cd8
7
- data.tar.gz: 9deb1429d08fcd8960d829e7e0dd15c2f26ae2c9250f40555938e59c7e86e667c29c7a14852445dbba7071d1d1ed5b447cdaac18803da3c005fdc1c50abd8666
6
+ metadata.gz: '09e89f2b8fefbc51d505f7205a9298e4298332b3442597c45d13da17efe74ee9099ded49613aa432e377d303f83e1a607735c07b16b9e3dfa91b52b556b9d43f'
7
+ data.tar.gz: 6f6b831daa3db4d01feafdf73103098cf95f0c7ad3e058ec074ccf984b339605772fc799f45241a9fb6cac490499b86943e8f7f268ff43113f79276d9146ca88
data/README.md CHANGED
@@ -216,7 +216,7 @@ As an example here we're setting `module_name` in Google's Advertising SDK:
216
216
  }
217
217
  ```
218
218
 
219
- ### `skip_pods`
219
+ #### `skip_pods`
220
220
 
221
221
  You may want to skip some pods to be prebuilt, you can do that as follows:
222
222
 
@@ -229,7 +229,7 @@ You may want to skip some pods to be prebuilt, you can do that as follows:
229
229
  ```
230
230
 
231
231
 
232
- ### `force_prebuild_pods`
232
+ #### `force_prebuild_pods`
233
233
 
234
234
  You may want to force some pods to be prebuilt, this might be the case for prebuilt ones (pods with a single vendored .framework) which are dependencies of othere pods
235
235
 
@@ -244,7 +244,9 @@ You may want to force some pods to be prebuilt, this might be the case for prebu
244
244
 
245
245
  #### `build_settings`
246
246
 
247
- Xcode build settings to use. You can override the default values which are:
247
+ These settings allow you to specify the build settings to use when compiling prebuilt items. These values won't be reflected in your project once the pod has been built.
248
+
249
+ You can override the default values which are:
248
250
 
249
251
  ```json
250
252
  {
@@ -362,7 +364,7 @@ Please open an issue here. You may also add the name of the pod to the [`skip_po
362
364
 
363
365
  # Git LFS
364
366
 
365
- We high encourage to use PodBuilder in combination with Git LFS. Tacking PodBuilder/Prebuilt/**/*.framework/* and PodBuilder/Prebuilt/**/*.a and PodBuilder/dSYM/**/* will ensure that your repo size stays under control with all the benefits of having prebuilt dependencies ready to use.
367
+ We high encourage to use PodBuilder in combination with Git LFS. Tacking `PodBuilder/Prebuilt/**/*.framework/*` and `PodBuilder/Prebuilt/**/*.a` and `PodBuilder/dSYM/**/*` will ensure that your repo size stays under control with all the benefits of having prebuilt dependencies ready to use.
366
368
 
367
369
 
368
370
  # Try it out!
data/exe/pod_builder CHANGED
@@ -76,9 +76,6 @@ Options:
76
76
  opts.on("-w", "--allow-warnings", "Allow warnings") do |o|
77
77
  OPTIONS[:allow_warnings] = o
78
78
  end
79
- opts.on("-r", "--parent-deps", "Include all pods that depend on the specified <PODNAME...>") do |o|
80
- OPTIONS[:resolve_parent_dependencies] = true
81
- end
82
79
  opts.on("-s", "--no-stdin", "Never request interaction with sdtin (e.g. in CI environment)") do |o|
83
80
  OPTIONS[:no_stdin_available] = o
84
81
  end
@@ -32,8 +32,6 @@ module PodBuilder
32
32
  argument_pods = all_buildable_items.map(&:root_name).uniq
33
33
  else
34
34
  argument_pods = Podfile::resolve_pod_names(argument_pods, all_buildable_items)
35
- deps = all_buildable_items.select { |t| argument_pods.include?(t.root_name) }.map(&:dependency_names).flatten.map { |t| t.split("/").first }
36
- argument_pods += deps
37
35
  argument_pods.uniq!
38
36
  end
39
37
 
@@ -43,8 +41,6 @@ module PodBuilder
43
41
  }
44
42
  argument_pods = available_argument_pods.uniq
45
43
 
46
- prebuilt_pods_to_install = prebuilt_items.select { |x| argument_pods.include?(x.root_name) }
47
-
48
44
  Podfile.restore_podfile_clean(all_buildable_items)
49
45
 
50
46
  restore_file_error = Podfile.restore_file_sanity_check
@@ -54,12 +50,25 @@ module PodBuilder
54
50
  pods_to_build = resolve_pods_to_build(argument_pods, buildable_items)
55
51
  buildable_items -= pods_to_build
56
52
 
57
- # We need to split pods to build in 3 groups
53
+ argument_pods += pods_to_build.map(&:root_name)
54
+ argument_pods.uniq!
55
+
56
+ # We need to split pods to build in 4 groups
58
57
  # 1. pods to build in release
59
58
  # 2. pods to build in debug
59
+ # 3. pods to build in release as xcframeworks
60
+ # 4. pods to build in debug as xcframeworks
60
61
 
61
62
  check_not_building_development_pods(pods_to_build)
62
63
 
64
+ # We need to recursively add dependencies to properly split pods in groups.
65
+ # Example:
66
+ # 1. PodA has a dep to PodB
67
+ # 2. PodB is marked to be built as xcframework
68
+ # 3. We rebuild PodA only (pods_to_build contains only PodA)
69
+ # 4. We need to add dependencies recursively so that PodB is is added to pods_to_build_release_xcframework
70
+ pods_to_build = pods_to_build.map { |t| t.recursive_dependencies(all_buildable_items) }.flatten.uniq
71
+
63
72
  pods_to_build_debug = pods_to_build.select { |x| x.build_configuration == "debug" }
64
73
  pods_to_build_release = pods_to_build - pods_to_build_debug
65
74
 
@@ -82,12 +91,12 @@ module PodBuilder
82
91
  install_using_frameworks = Podfile::install_using_frameworks(analyzer)
83
92
  if Configuration.react_native_project
84
93
  if install_using_frameworks
85
- raise "\n\nOnly static library packaging currently supported for react native projects. Please remove 'use_frameworks!' in #{PodBuilder::basepath("Podfile")}".red
94
+ raise "\n\nOnly static library packaging currently supported for react native projects. Please remove 'use_frameworks!' in #{PodBuilder::basepath("Podfile")}\n".red
86
95
  end
87
96
  prepare_defines_modules_override(all_buildable_items)
88
97
  else
89
98
  unless install_using_frameworks
90
- raise "\n\nOnly framework packaging currently supported. Please add 'use_frameworks!' at root level (not nested in targets) in #{PodBuilder::basepath("Podfile")}".red
99
+ raise "\n\nOnly framework packaging currently supported. Please add 'use_frameworks!' at root level (not nested in targets) in #{PodBuilder::basepath("Podfile")}\n".red
91
100
  end
92
101
  end
93
102
 
@@ -96,12 +105,17 @@ module PodBuilder
96
105
  install_result = InstallResult.new
97
106
  podfiles_items.reject { |x| x.empty? }.each do |podfile_items|
98
107
  build_configuration = podfile_items.map(&:build_configuration).uniq.first
99
-
100
- podfile_items = podfile_items.map { |t| t.recursive_dependencies(all_buildable_items) }.flatten.uniq
101
108
 
109
+ # We need to recursively find dependencies again because some of the required dependencies might have been moved to a separate group
110
+ # Example:
111
+ # 1. PodA has a dep to PodB
112
+ # 2. PodB is marked to be built as xcframework -> PodB will be added to pods_to_build_release_xcframework and won't be present in
113
+ # pods_to_build_release and therefore build will fail
114
+ podfile_items = podfile_items.map { |t| t.recursive_dependencies(all_buildable_items) }.flatten.uniq
115
+
102
116
  podfile_content = Podfile.from_podfile_items(podfile_items, analyzer, build_configuration, install_using_frameworks, build_catalyst, podfile_items.first.build_xcframework)
103
117
 
104
- install_result += Install.podfile(podfile_content, podfile_items, podfile_items.first.build_configuration)
118
+ install_result += Install.podfile(podfile_content, podfile_items, argument_pods, podfile_items.first.build_configuration)
105
119
 
106
120
  FileUtils.rm_f(PodBuilder::basepath("Podfile.lock"))
107
121
  end
@@ -119,6 +133,7 @@ module PodBuilder
119
133
  builded_pods_and_deps = podfiles_items.flatten.map { |t| t.recursive_dependencies(all_buildable_items) }.flatten.uniq
120
134
  builded_pods_and_deps.select! { |x| !x.is_prebuilt }
121
135
 
136
+ prebuilt_pods_to_install = prebuilt_items.select { |x| argument_pods.include?(x.root_name) }
122
137
  Podfile::write_restorable(builded_pods_and_deps + prebuilt_pods_to_install, all_buildable_items, analyzer)
123
138
  if !OPTIONS.has_key?(:skip_prebuild_update)
124
139
  Podfile::write_prebuilt(all_buildable_items, analyzer)
@@ -142,7 +157,7 @@ module PodBuilder
142
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
143
158
  build_catalyst = build_settings.detect { |t| t["SUPPORTS_MACCATALYST"] == "YES" } != nil
144
159
 
145
- puts "\nTo support Catalyst you should enable 'build_xcframeworks' in PodBuilder.json\n".red if build_catalyst && !Configuration.build_xcframeworks
160
+ puts "\nTo support Catalyst you should enable 'build_xcframeworks' in PodBuilder.json\n".red if build_catalyst && !Configuration.build_xcframeworks_all
146
161
 
147
162
  return build_catalyst
148
163
  end
@@ -164,11 +179,11 @@ module PodBuilder
164
179
  end
165
180
 
166
181
  def self.check_pods_exists(pods, buildable_items)
167
- raise "\n\nEmpty Podfile?".red if buildable_items.nil?
182
+ raise "\n\nEmpty Podfile?\n".red if buildable_items.nil?
168
183
 
169
184
  buildable_items = buildable_items.map(&:root_name)
170
185
  pods.each do |pod|
171
- raise "\n\nPod `#{pod}` wasn't found in Podfile.\n\nFound:\n#{buildable_items.join("\n")}\n\n".red if !buildable_items.include?(pod)
186
+ raise "\n\nPod `#{pod}` wasn't found in Podfile.\n\nFound:\n#{buildable_items.join("\n")}\n".red if !buildable_items.include?(pod)
172
187
  end
173
188
  end
174
189
 
@@ -182,7 +197,7 @@ module PodBuilder
182
197
  pods_with_unaligned_build_configuration = pods_with_common_deps.select { |x| x.build_configuration != pod.build_configuration }
183
198
  pods_with_unaligned_build_configuration.map!(&:name)
184
199
 
185
- raise "\n\nDependencies of `#{pod.name}` don't have the same build configuration (#{pod.build_configuration}) of `#{pods_with_unaligned_build_configuration.join(",")}`'s dependencies".red if pods_with_unaligned_build_configuration.count > 0
200
+ raise "\n\nDependencies of `#{pod.name}` don't have the same build configuration (#{pod.build_configuration}) of `#{pods_with_unaligned_build_configuration.join(",")}`'s dependencies\n".red if pods_with_unaligned_build_configuration.count > 0
186
201
  end
187
202
  end
188
203
 
@@ -213,7 +228,7 @@ module PodBuilder
213
228
  if OPTIONS[:allow_warnings]
214
229
  puts "\n\n#{warn_message}".yellow
215
230
  else
216
- raise "\n\n#{warn_message}".red
231
+ raise "\n\n#{warn_message}\n".red
217
232
  end
218
233
  end
219
234
  end
@@ -224,15 +239,17 @@ module PodBuilder
224
239
  pods_to_build = buildable_items.select { |x| argument_pods.include?(x.root_name) }
225
240
  pods_to_build += other_subspecs(pods_to_build, buildable_items)
226
241
 
227
- if OPTIONS[:resolve_parent_dependencies]
228
- dependencies = []
229
- buildable_items.each do |pod|
230
- if !(pod.dependencies(buildable_items) & pods_to_build).empty?
231
- dependencies.push(pod)
232
- end
242
+ # Build all pods that depend on the those that were explictly passed by the user
243
+ dependencies = []
244
+ buildable_items.each do |pod|
245
+ if !(pod.dependencies(buildable_items) & pods_to_build).empty?
246
+ dependencies.push(pod)
233
247
  end
234
- pods_to_build += dependencies
235
248
  end
249
+ log = dependencies.reject { |t| pods_to_build.map(&:root_name).include?(t.root_name) }.map(&:root_name)
250
+ puts "Adding inverse dependencies: #{log.join(", ")}".blue
251
+
252
+ pods_to_build += dependencies
236
253
 
237
254
  return pods_to_build.uniq
238
255
  end
@@ -19,7 +19,7 @@ module PodBuilder
19
19
  end
20
20
  source_path = File.expand_path(source_path)
21
21
 
22
- raise "\n\nSpecified path does not exists" unless File.directory?(source_path)
22
+ raise "\n\nSpecified path does not exists\n".red unless File.directory?(source_path)
23
23
  end
24
24
 
25
25
  base_path = PodBuilder::basepath
@@ -122,11 +122,11 @@ module PodBuilder
122
122
  # React-Core.podspec
123
123
  file = "React-Core.podspec"
124
124
  paths = Dir.glob("#{PodBuilder::git_rootpath}/node_modules/**/#{file}")
125
- raise "Unexpected number of #{file} found" if paths.count != 1
125
+ raise "\n\nUnexpected number of #{file} found\n".red if paths.count != 1
126
126
 
127
127
  content = File.read(paths[0])
128
128
  expected_header_search_path_prefix = "s.pod_target_xcconfig = { \"HEADER_SEARCH_PATHS\" => \""
129
- raise "Expected header search path entry not found" unless content.include?(expected_header_search_path_prefix)
129
+ raise "\n\nExpected header search path entry not found\n".red unless content.include?(expected_header_search_path_prefix)
130
130
 
131
131
  content.sub!(expected_header_search_path_prefix, "#{expected_header_search_path_prefix}\\\"$(PODS_ROOT)/Headers/Public/Flipper-Folly\\\" ")
132
132
  File.write(paths[0], content)
@@ -134,11 +134,11 @@ module PodBuilder
134
134
  # React-CoreModules.podspec
135
135
  file = "React-CoreModules.podspec"
136
136
  paths = Dir.glob("#{PodBuilder::git_rootpath}/node_modules/**/#{file}")
137
- raise "Unexpected number of #{file} found" if paths.count != 1
137
+ raise "\n\nUnexpected number of #{file} found\n".red if paths.count != 1
138
138
 
139
139
  content = File.read(paths[0])
140
140
  expected_header_search_path_prefix = "\"HEADER_SEARCH_PATHS\" => \""
141
- raise "Expected header search path entry not found" unless content.include?(expected_header_search_path_prefix)
141
+ raise "\n\nExpected header search path entry not found\n".red unless content.include?(expected_header_search_path_prefix)
142
142
 
143
143
  content.sub!(expected_header_search_path_prefix, "#{expected_header_search_path_prefix}\\\"$(PODS_ROOT)/Headers/Public/Flipper-Folly\\\" ")
144
144
  File.write(paths[0], content)
@@ -13,19 +13,23 @@ module PodBuilder
13
13
  return -1
14
14
  end
15
15
 
16
+ pods_not_found = []
16
17
  pod_names_to_switch = []
17
18
  argument_pods.each do |pod|
18
19
  pod_name_to_switch = pod
19
20
  pod_name_to_switch = Podfile::resolve_pod_names_from_podfile([pod_name_to_switch]).first
20
- raise "\n\nDid not find pod '#{pod}'".red if pod_name_to_switch.nil?
21
-
22
- check_not_building_subspec(pod_name_to_switch)
23
21
 
24
- pod_names_to_switch.push(pod_name_to_switch)
22
+ if pod_name_to_switch.nil?
23
+ raise "\n\n'#{pod}' not found in PodBuilder's Podfile.\n\nYou might need to explictly add:\n\n pod '#{pod}'\n\nto #{PodBuilder::basepath("Podfile")}\n".red
24
+ else
25
+ check_not_building_subspec(pod_name_to_switch)
26
+
27
+ pod_names_to_switch.push(pod_name_to_switch)
28
+ end
25
29
  end
26
30
 
27
31
  if OPTIONS[:resolve_parent_dependencies] == true
28
- install_update_repo = OPTIONS.fetch(:update_repos, true)
32
+ install_update_repo = OPTIONS.fetch(:update_repos, false)
29
33
  installer, analyzer = Analyze.installer_at(PodBuilder::basepath, install_update_repo)
30
34
 
31
35
  all_buildable_items = Analyze.podfile_items(installer, analyzer)
@@ -55,7 +59,7 @@ module PodBuilder
55
59
 
56
60
  podspec_content = File.read(podspec_path)
57
61
 
58
- regex = "p\\d\\.dependency '(.*)'"
62
+ regex = "p\\d\\.dependency ['|\"](.*)['|\"]"
59
63
 
60
64
  podspec_content.each_line do |line|
61
65
  matches = line.match(/#{regex}/)
@@ -107,15 +111,15 @@ module PodBuilder
107
111
  next
108
112
  end
109
113
 
110
- matches = line.gsub("\"", "'").match(/pod '(.*?)',(.*)/)
111
- if matches&.size == 3
114
+ matches = line.gsub("\"", "'").match(/pod '(.*?)'/)
115
+ if matches&.size == 2
112
116
  if matches[1].split("/").first == pod_name_to_switch
113
117
  default_entries[current_section] = line
114
118
  end
115
119
  end
116
120
  end
117
121
 
118
- raise "\n\n'#{pod_name_to_switch}' not found in #{podfile_path}".red if default_entries.keys.count == 0
122
+ raise "\n\n'#{pod_name_to_switch}' not found in PodBuilder's Podfile.\n\nYou might need to explictly add:\n\n pod '#{pod_name_to_switch}'\n\nto #{podfile_path}\n".red if default_entries.keys.count == 0
119
123
  end
120
124
 
121
125
  if development_path.nil?
@@ -137,8 +141,8 @@ module PodBuilder
137
141
  current_section = line.split(" ")[1]
138
142
  end
139
143
 
140
- matches = line.gsub("\"", "'").match(/pod '(.*?)',(.*)/)
141
- if matches&.size == 3
144
+ matches = line.gsub("\"", "'").match(/pod '(.*?)'/)
145
+ if matches&.size == 2
142
146
  if matches[1].split("/").first == pod_name_to_switch
143
147
  case OPTIONS[:switch_mode]
144
148
  when "prebuilt"
@@ -166,6 +170,14 @@ module PodBuilder
166
170
  if line.include?("# pb<") && marker = line.split("# pb<").last
167
171
  default_line = default_line.chomp("\n") + " # pb<#{marker}"
168
172
  end
173
+ if (path_match = default_line.match(/:path => '(.*?)'/)) && path_match&.size == 2
174
+ original_path = path_match[1]
175
+ if !is_absolute_path(original_path)
176
+ updated_path = Pathname.new(PodBuilder::basepath(original_path)).relative_path_from(Pathname.new(PodBuilder::project_path)).to_s
177
+ default_line.gsub!(":path => '#{original_path}'", ":path => '#{updated_path}'")
178
+ end
179
+ end
180
+
169
181
  lines.append(default_line)
170
182
  next
171
183
  elsif
@@ -190,7 +202,11 @@ module PodBuilder
190
202
  return 0
191
203
  end
192
204
 
193
- private
205
+ private
206
+
207
+ def self.is_absolute_path(path)
208
+ return ["~", "/"].any? { |t| path.start_with?(t) }
209
+ end
194
210
 
195
211
  def self.find_podspec(podname)
196
212
  unless Configuration.development_pods_paths.count > 0
@@ -216,7 +232,7 @@ module PodBuilder
216
232
 
217
233
  def self.check_not_building_subspec(pod_to_switch)
218
234
  if pod_to_switch.include?("/")
219
- raise "\n\nCan't switch subspec #{pod_to_switch} refer to podspec name.\n\nUse `pod_builder switch #{pod_to_switch.split("/").first}` instead\n\n".red
235
+ raise "\n\nCan't switch subspec #{pod_to_switch} refer to podspec name.\n\nUse `pod_builder switch #{pod_to_switch.split("/").first}` instead\n".red
220
236
  end
221
237
  end
222
238
  end
@@ -35,7 +35,6 @@ module PodBuilder
35
35
  ARGV.clear
36
36
  pods_to_update.each { |x| ARGV << x }
37
37
 
38
- # OPTIONS[:resolve_parent_dependencies] = true
39
38
  return PodBuilder::Command::Build.call
40
39
  end
41
40
  end
@@ -286,9 +286,9 @@ module PodBuilder
286
286
  end
287
287
  end
288
288
  if Configuration.build_xcframeworks_all
289
- raise "Invalid PodBuilder.json configuration: 'build_xcframeworks_all' is true and 'build_xcframeworks_include' is not empty" if Configuration.build_xcframeworks_include.count > 0
289
+ raise "\n\nInvalid PodBuilder.json configuration: 'build_xcframeworks_all' is true and 'build_xcframeworks_include' is not empty\n".red if Configuration.build_xcframeworks_include.count > 0
290
290
  else
291
- raise "Invalid PodBuilder.json configuration: 'build_xcframeworks_all' is false and 'build_xcframeworks_exclude' is not empty" if Configuration.build_xcframeworks_exclude.count > 0
291
+ raise "\n\nInvalid PodBuilder.json configuration: 'build_xcframeworks_all' is false and 'build_xcframeworks_exclude' is not empty\n".red if Configuration.build_xcframeworks_exclude.count > 0
292
292
  end
293
293
  end
294
294
 
@@ -132,7 +132,7 @@ module PodBuilder
132
132
  folder_in_home = x.gsub(home, "")
133
133
  !folder_in_home.include?("/Pods/") && !x.include?(PodBuilder::basepath("Sources")) && !x.include?(PodBuilder::basepath + "/")
134
134
  }
135
- raise "\n\nxcodeproj not found!".red if xcodeprojects.count == 0
135
+ raise "\n\nxcodeproj not found!\n".red if xcodeprojects.count == 0
136
136
  raise "\n\nFound multiple xcodeproj:\n#{xcodeprojects.join("\n")}".red if xcodeprojects.count > 1
137
137
 
138
138
  @@xcodeproj_path = xcodeprojects.first
@@ -148,7 +148,7 @@ module PodBuilder
148
148
  folder_in_home = x.gsub(home, "")
149
149
  !folder_in_home.include?("/Pods/") && !x.include?(PodBuilder::basepath("Sources")) && !x.include?(PodBuilder::basepath + "/") && !x.include?(".xcodeproj/")
150
150
  }
151
- raise "\n\nxcworkspace not found!".red if xcworkspaces.count == 0
151
+ raise "\n\nxcworkspace not found!\n".red if xcworkspaces.count == 0
152
152
  raise "\n\nFound multiple xcworkspaces:\n#{xcworkspaces.join("\n")}".red if xcworkspaces.count > 1
153
153
 
154
154
  @@xcodeworkspace_path = xcworkspaces.first
@@ -179,7 +179,7 @@ module PodBuilder
179
179
 
180
180
  def self.system_swift_version
181
181
  swift_version = `swiftc --version | grep -o 'swiftlang-.*\s'`.strip()
182
- raise "\n\nUnsupported swift compiler version, expecting `swiftlang` keyword in `swiftc --version`".red if swift_version.length == 0
182
+ raise "\n\nUnsupported swift compiler version, expecting `swiftlang` keyword in `swiftc --version`\n".red if swift_version.length == 0
183
183
  return swift_version
184
184
  end
185
185
 
@@ -60,7 +60,7 @@ module PodBuilder
60
60
 
61
61
  return { "repo": "local" }
62
62
  else
63
- raise "\n\nFailed extracting version from line:\n#{line}\n\n".red
63
+ raise "\n\nFailed extracting version from line:\n#{line}\n".red
64
64
  end
65
65
  end
66
66
 
@@ -45,7 +45,7 @@ begin
45
45
  elsif defined?(Pod::Target::BuildType) # CocoaPods 1.7, 1.8
46
46
  Pod::Target::BuildType.new(linkage: :dynamic, packaging: :framework)
47
47
  else
48
- raise "\n\nBuildType not found. Open an issue reporting your CocoaPods version".red
48
+ raise "\n\nBuildType not found. Open an issue reporting your CocoaPods version\n".red
49
49
  end
50
50
  else
51
51
  swz_build_type()
@@ -139,7 +139,7 @@ module PodBuilder
139
139
 
140
140
  class Install
141
141
  # This method will generate prebuilt data by building from "/tmp/pod_builder/Podfile"
142
- def self.podfile(podfile_content, podfile_items, build_configuration)
142
+ def self.podfile(podfile_content, podfile_items, argument_pods, build_configuration)
143
143
  puts "Preparing build Podfile".yellow
144
144
 
145
145
  PodBuilder::safe_rm_rf(Configuration.build_path)
@@ -160,7 +160,7 @@ module PodBuilder
160
160
  lock_file = "#{Configuration.build_path}/pod_builder.lock"
161
161
  FileUtils.touch(lock_file)
162
162
 
163
- prebuilt_entries = use_prebuilt_entries_for_unchanged_pods(podfile_path, podfile_items)
163
+ prebuilt_entries = use_prebuilt_entries_for_unchanged_pods(podfile_path, podfile_items, argument_pods)
164
164
 
165
165
  install
166
166
 
@@ -247,7 +247,7 @@ module PodBuilder
247
247
  def self.license_specifiers
248
248
  acknowledge_file = "#{Configuration.build_path}/Pods/Target Support Files/Pods-DummyTarget/Pods-DummyTarget-acknowledgements.plist"
249
249
  unless File.exist?(acknowledge_file)
250
- raise "\n\nLicense file not found".red
250
+ raise "\n\nLicense file not found\n".red
251
251
  end
252
252
 
253
253
  plist = CFPropertyList::List.new(:file => acknowledge_file)
@@ -280,45 +280,67 @@ module PodBuilder
280
280
  return podfile_content
281
281
  end
282
282
 
283
- def self.use_prebuilt_entries_for_unchanged_pods(podfile_path, podfile_items)
283
+ def self.use_prebuilt_entries_for_unchanged_pods(podfile_path, podfile_items, argument_pods)
284
284
  podfile_content = File.read(podfile_path)
285
285
 
286
286
  replaced_items = []
287
287
 
288
- if OPTIONS.has_key?(:force_rebuild)
289
- podfile_content.gsub!("%%%prebuilt_root_paths%%%", "{}")
290
- else
291
- download # Copy files under #{Configuration.build_path}/Pods so that we can determine build folder hashes
288
+ download # Copy files under #{Configuration.build_path}/Pods so that we can determine build folder hashes
292
289
 
293
- gitignored_files = PodBuilder::gitignoredfiles
290
+ gitignored_files = PodBuilder::gitignoredfiles
294
291
 
295
- prebuilt_root_paths = Hash.new
292
+ prebuilt_root_paths = Hash.new
296
293
 
297
- # Replace prebuilt entries in Podfile for Pods that have no changes in source code which will avoid rebuilding them
298
- items = podfile_items.group_by { |t| t.root_name }.map { |k, v| v.first } # Return one podfile_item per root_name
299
- items.each do |item|
300
- podspec_path = item.prebuilt_podspec_path
301
- if last_build_folder_hash = build_folder_hash_in_prebuilt_info_file(item)
302
- if last_build_folder_hash == build_folder_hash(item, gitignored_files)
303
- puts "No changes detected to '#{item.root_name}', will skip rebuild".blue
294
+ puts "Optimizing build".yellow
295
+ puts "Build strategy".blue
304
296
 
305
- replaced_items.push(item)
297
+ prebuild_log = lambda { |item, reason|
298
+ if item.is_prebuilt
299
+ puts "#{item.root_name} is prebuilt"
300
+ else
301
+ puts "#{item.root_name} from source #{reason}".blue
302
+ end
303
+ }
306
304
 
307
- podfile_items.select { |t| t.root_name == item.root_name }.each do |replace_item|
308
- replace_regex = "pod '#{Regexp.quote(replace_item.name)}', .*"
309
- replace_line_found = podfile_content =~ /#{replace_regex}/i
310
- raise "\n\nFailed finding pod entry for '#{replace_item.name}'".red unless replace_line_found
311
- podfile_content.gsub!(/#{replace_regex}/, replace_item.prebuilt_entry(true, true))
305
+ # Replace prebuilt entries in Podfile for Pods that have no changes in source code which will avoid rebuilding them
306
+ items = podfile_items.group_by { |t| t.root_name }.map { |k, v| v.first }.sort_by { |t| t.root_name } # Return one podfile_item per root_name
307
+ if OPTIONS.has_key?(:force_rebuild)
308
+ rebuild_pods = items.select { |t| argument_pods.include?(t.root_name) }
312
309
 
313
- prebuilt_root_paths[replace_item.root_name] = PodBuilder::prebuiltpath
314
- end
315
- end
316
- end
310
+ rebuild_pods.each do |item|
311
+ prebuild_log.call(item, "")
312
+ end
313
+
314
+ items -= rebuild_pods
315
+ end
316
+
317
+ items.each do |item|
318
+ podspec_path = item.prebuilt_podspec_path
319
+ unless last_build_folder_hash = build_folder_hash_in_prebuilt_info_file(item)
320
+ prebuild_log.call(item, "(folder hash missing)")
321
+ next
317
322
  end
323
+
324
+ if last_build_folder_hash == build_folder_hash(item, gitignored_files)
325
+ puts "#{item.root_name} reuse PodBuilder cache"
318
326
 
319
- podfile_content.gsub!("%%%prebuilt_root_paths%%%", prebuilt_root_paths.to_s)
327
+ replaced_items.push(item)
328
+
329
+ podfile_items.select { |t| t.root_name == item.root_name }.each do |replace_item|
330
+ replace_regex = "pod '#{Regexp.quote(replace_item.name)}', .*"
331
+ replace_line_found = podfile_content =~ /#{replace_regex}/i
332
+ raise "\n\nFailed finding pod entry for '#{replace_item.name}'\n".red unless replace_line_found
333
+ podfile_content.gsub!(/#{replace_regex}/, replace_item.prebuilt_entry(true, true))
334
+
335
+ prebuilt_root_paths[replace_item.root_name] = PodBuilder::prebuiltpath
336
+ end
337
+ else
338
+ prebuild_log.call(item, "(folder hash mismatch)")
339
+ end
320
340
  end
321
341
 
342
+ podfile_content.gsub!("%%%prebuilt_root_paths%%%", prebuilt_root_paths.to_s)
343
+
322
344
  File.write(podfile_path, podfile_content)
323
345
 
324
346
  return replaced_items
@@ -457,15 +479,16 @@ module PodBuilder
457
479
  unless File.file?(path)
458
480
  next
459
481
  end
460
-
482
+
461
483
  path = File.expand_path(path)
462
484
  rel_path = path.gsub(rootpath, "")[1..]
463
- unless exclude_files.include?(rel_path)
485
+
486
+ unless exclude_files.any? { |t| rel_path.start_with?(t) }
464
487
  file_hashes.push(Digest::MD5.hexdigest(File.read(path)))
465
488
  end
466
489
  end
467
490
 
468
- return Digest::MD5.hexdigest(file_hashes.join)
491
+ return Digest::MD5.hexdigest(file_hashes.sort.join)
469
492
  else
470
493
  # Pod folder might be under .gitignore
471
494
  item_path = "#{Configuration.build_path}/Pods/#{podfile_item.root_name}"
@@ -12,19 +12,19 @@
12
12
 
13
13
  if current_licenses.count > 0
14
14
  licenses_header = current_licenses.shift
15
- raise "\n\nUnexpected license found in header".red if licenses_header.has_key?("License")
15
+ raise "\n\nUnexpected license found in header\n".red if licenses_header.has_key?("License")
16
16
  end
17
17
  if current_licenses.count > 0
18
18
  license_footer = current_licenses.pop
19
- raise "\n\nUnexpected license found in footer".red if license_footer.has_key?("License")
19
+ raise "\n\nUnexpected license found in footer\n".red if license_footer.has_key?("License")
20
20
  end
21
21
  end
22
22
 
23
23
  if licenses.count > 0
24
24
  licenses_header = licenses.shift
25
- raise "\n\nUnexpected license found in header".red if licenses_header.has_key?("License")
25
+ raise "\n\nUnexpected license found in header\n".red if licenses_header.has_key?("License")
26
26
  license_footer = licenses.pop
27
- raise "\n\nUnexpected license found in footer".red if license_footer.has_key?("License")
27
+ raise "\n\nUnexpected license found in footer\n".red if license_footer.has_key?("License")
28
28
 
29
29
  lincenses_titles = licenses.map { |x| x["Title"] }
30
30
  current_licenses.select! { |x| !lincenses_titles.include?(x["Title"]) }
@@ -6,7 +6,7 @@ module PodBuilder
6
6
  PRE_INSTALL_ACTIONS = ["Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_duplicate_framework_and_library_names) {}", "require 'pod_builder/podfile/pre_actions_swizzles'"].freeze
7
7
 
8
8
  def self.from_podfile_items(items, analyzer, build_configuration, install_using_frameworks, build_catalyst, build_xcframeworks)
9
- raise "\n\nno items".red unless items.count > 0
9
+ raise "\n\nno items\n".red unless items.count > 0
10
10
 
11
11
  sources = analyzer.sources
12
12
 
@@ -354,7 +354,7 @@ module PodBuilder
354
354
 
355
355
  if stripped_line.match(/(pod')(.*?)(')/) != nil
356
356
  starting_def_found = stripped_line.start_with?("def") && (line.match("\s*def\s") != nil)
357
- raise "\n\nUnsupported single line def/pod. `def` and `pod` shouldn't be on the same line, please modify the following line:\n#{line}".red if starting_def_found
357
+ raise "\n\nUnsupported single line def/pod. `def` and `pod` shouldn't be on the same line, please modify the following line:\n#{line}\n".red if starting_def_found
358
358
  end
359
359
  end
360
360
  end
@@ -396,9 +396,9 @@ module PodBuilder
396
396
  if target_settings.count == 1
397
397
  return target_settings.first
398
398
  elsif target_settings.count > 1
399
- raise "\n\n'use_frameworks!' should be declared only once at Podfile root level (not nested in targets)".red
399
+ raise "\n\n'use_frameworks!' should be declared only once at Podfile root level (not nested in targets)\n".red
400
400
  else
401
- raise "\n\nFailed detecting use_frameworks!"
401
+ raise "\n\nFailed detecting use_frameworks!\n".red
402
402
  end
403
403
 
404
404
  return true
@@ -443,13 +443,13 @@ module PodBuilder
443
443
  def self.project_swift_version(analyzer)
444
444
  swift_versions = analyzer.instance_variable_get("@result").targets.map { |x| x.target_definition.swift_version }.compact.uniq
445
445
 
446
- raise "\n\nFound different Swift versions in targets. Expecting one, got `#{swift_versions}`".red if swift_versions.count > 1
446
+ raise "\n\nFound different Swift versions in targets. Expecting one, got `#{swift_versions}`\n".red if swift_versions.count > 1
447
447
 
448
448
  return swift_versions.first || PodBuilder::system_swift_version
449
449
  end
450
450
 
451
451
  def self.podfile_items_at(podfile_path, include_prebuilt = false)
452
- raise "\n\nExpecting basepath folder!".red if !File.exist?(PodBuilder::basepath("Podfile"))
452
+ raise "\n\nExpecting basepath folder!\n".red if !File.exist?(PodBuilder::basepath("Podfile"))
453
453
 
454
454
  if File.basename(podfile_path) != "Podfile"
455
455
  File.rename(PodBuilder::basepath("Podfile"), PodBuilder::basepath("Podfile.tmp"))
@@ -607,12 +607,12 @@ module PodBuilder
607
607
  base = File.expand_path(File.join(PodBuilder::project_path, ".."))
608
608
  bin_js = Dir.glob("#{base}/node_modules/@react-native-community/cli/build/bin.js")
609
609
 
610
- raise "\n\nReact native cli bin_js not found! Did you run yarn install?".red unless bin_js.count == 1
610
+ raise "\n\nReact native cli bin_js not found! Did you run yarn install?\n".red unless bin_js.count == 1
611
611
  bin_js = bin_js.first
612
612
 
613
613
  config_dest_path = PodBuilder::basepath("rn_config.json")
614
614
 
615
- raise "\n\nFailed generating react native configuration file".red unless system("node '#{bin_js}' config > #{config_dest_path}")
615
+ raise "\n\nFailed generating react native configuration file\n".red unless system("node '#{bin_js}' config > #{config_dest_path}")
616
616
 
617
617
  content = File.read(config_dest_path)
618
618
 
@@ -624,7 +624,7 @@ module PodBuilder
624
624
  json["project"]["ios"]["sourceDir"] = "./"
625
625
  json["project"]["ios"]["podfile"] = "./"
626
626
  rescue => exception
627
- raise "\n\nFailed updating react native configuration json".red
627
+ raise "\n\nFailed updating react native configuration json\n".red
628
628
  end
629
629
 
630
630
  File.write(config_dest_path, JSON.pretty_generate(json))
@@ -24,7 +24,7 @@ class Pod::Generator::EmbedFrameworksScript
24
24
  alias_method :swz_initialize, :initialize
25
25
 
26
26
  def initialize(*args)
27
- raise "Unsupported CocoaPods version" if (args.count == 0 || args.count > 2)
27
+ raise "\n\nUnsupported CocoaPods version\n".red if (args.count == 0 || args.count > 2)
28
28
 
29
29
  frameworks_by_config = args[0]
30
30
  frameworks_by_config.keys.each do |key|
@@ -142,7 +142,7 @@ module PodBuilder
142
142
  end
143
143
  if !install_using_frameworks && spec_var == "p1" && vendored_libraries.map { |t| File.basename(t) }.include?("lib#{item.root_name}.a" )
144
144
  module_path_files = Dir.glob(PodBuilder.prebuiltpath("#{item.root_name}/**/#{item.root_name}.modulemap"))
145
- raise "\n\nToo many module maps found for #{item.root_name}".red if module_path_files.count > 1
145
+ raise "\n\nToo many module maps found for #{item.root_name}\n".red if module_path_files.count > 1
146
146
 
147
147
  rel_path = Pathname.new(PodBuilder::prebuiltpath).relative_path_from(Pathname.new(PodBuilder::project_path("Pods"))).to_s
148
148
  prebuilt_root_var = "#{item.root_name.upcase.gsub("-", "_")}_PREBUILT_ROOT"
@@ -21,7 +21,7 @@ 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}'".red end
24
+ else raise "\n\nUnknown platform '#{platform_name}'\n".red end
25
25
  end
26
26
  end
27
27
 
@@ -65,7 +65,7 @@ module PodBuilder
65
65
  `xcrun lipo -remove arm64 #{simulator_lib} -o #{simulator_lib}`
66
66
  end
67
67
 
68
- raise "Lipo failed on #{device_lib}" unless system("xcrun lipo -create -output #{device_lib} #{device_lib} #{simulator_lib}")
68
+ raise "\n\nLipo failed on #{device_lib}\n".red unless system("xcrun lipo -create -output #{device_lib} #{device_lib} #{simulator_lib}")
69
69
 
70
70
  merge_header_into(device_swift_header_path, simulator_swift_header_path)
71
71
 
@@ -116,7 +116,7 @@ module PodBuilder
116
116
  `xcrun lipo -remove arm64 #{simulator_lib} -o #{simulator_lib}`
117
117
  end
118
118
 
119
- raise "Lipo failed on #{device_lib}" unless system("xcrun lipo -create -output #{device_lib} #{device_lib} #{simulator_lib}")
119
+ raise "\n\nLipo failed on #{device_lib}\n".red unless system("xcrun lipo -create -output #{device_lib} #{device_lib} #{simulator_lib}")
120
120
 
121
121
  device_headers = Dir.glob("#{device_base}/**/*.h")
122
122
  simulator_headers = Dir.glob("#{simulator_base}/**/*.h")
@@ -247,7 +247,7 @@ module PodBuilder
247
247
  output = stdout + stderr
248
248
  unless status.success?
249
249
  if raise_on_failure
250
- raise "#{full_command}\n\n#{output}"
250
+ raise "\n\n#{full_command}\n\n#{output}\n".red
251
251
  else
252
252
  UI.message("[!] Failed: #{full_command}".red)
253
253
  end
@@ -307,7 +307,7 @@ Pod::HooksManager.register('podbuilder-rome', :post_install) do |installer_conte
307
307
  build_dir.rmtree if build_dir.directory?
308
308
 
309
309
  targets = installer_context.umbrella_targets.select { |t| t.specs.any? }
310
- raise "\n\nUnsupported target count".red unless targets.count == 1
310
+ raise "\n\nUnsupported target count\n".red unless targets.count == 1
311
311
  target = targets.first
312
312
 
313
313
  if build_xcframeworks
@@ -322,11 +322,11 @@ Pod::HooksManager.register('podbuilder-rome', :post_install) do |installer_conte
322
322
  when :osx then xcodebuild_settings = [PodBuilder::XcodeBuildSettings.new("macos", configuration)]
323
323
  when :tvos then xcodebuild_settings = [PodBuilder::XcodeBuildSettings.new("tvos", configuration), PodBuilder::XcodeBuildSettings.new("tvossimulator", configuration)]
324
324
  when :watchos then xcodebuild_settings = [PodBuilder::XcodeBuildSettings.new("watchos", configuration), PodBuilder::XcodeBuildSettings.new("watchossimulator", configuration)]
325
- else raise "\n\nUnknown platform '#{target.platform_name}'".red end
325
+ else raise "\n\nUnknown platform '#{target.platform_name}'\n".red end
326
326
 
327
327
  xcodebuild_settings.each do |xcodebuild_setting|
328
328
  puts "Building xcframeworks for #{xcodebuild_setting.platform_name}".yellow
329
- raise "\n\n#{xcodebuild_setting.build_destination} xcframework archive failed!".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")
329
+ 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")
330
330
  end
331
331
 
332
332
  built_items = Dir.glob("#{build_dir}/#{xcodebuild_settings[0].platform_name}.xcarchive/Products/Library/Frameworks/*").reject { |t| File.basename(t, ".*") == "Pods_DummyTarget" }
@@ -348,7 +348,7 @@ Pod::HooksManager.register('podbuilder-rome', :post_install) do |installer_conte
348
348
  framework_name = File.basename(built_item_paths.first, ".*")
349
349
  xcframework_path = "#{base_destination}/#{framework_name}/#{framework_name}.xcframework"
350
350
  framework_params = built_item_paths.map { |t| "-framework '#{t}'"}.join(" ")
351
- raise "\n\nFailed packing xcframework!".red if !system("xcodebuild -create-xcframework #{framework_params} -output '#{xcframework_path}' > /dev/null 2>&1")
351
+ raise "\n\nFailed packing xcframework!\n".red if !system("xcodebuild -create-xcframework #{framework_params} -output '#{xcframework_path}' > /dev/null 2>&1")
352
352
 
353
353
  if enable_dsym
354
354
  xcodebuild_settings.each do |xcodebuild_setting|
@@ -361,7 +361,7 @@ Pod::HooksManager.register('podbuilder-rome', :post_install) do |installer_conte
361
361
  end
362
362
  end
363
363
  else
364
- raise "Not implemented"
364
+ raise "\n\nNot implemented\n".red
365
365
  end
366
366
  end
367
367
 
@@ -377,7 +377,7 @@ Pod::HooksManager.register('podbuilder-rome', :post_install) do |installer_conte
377
377
  when [:osx, false] then PodBuilder::xcodebuild(sandbox, target.cocoapods_target_label, configuration, PodBuilder::Configuration.deterministic_build, prebuilt_root_paths)
378
378
  when [:tvos, false] then PodBuilder::build_for_iosish_platform_lib(sandbox, build_dir, target, 'appletvos', 'appletvsimulator', configuration, PodBuilder::Configuration.deterministic_build, prebuilt_root_paths)
379
379
  when [:watchos, false] then PodBuilder::build_for_iosish_platform_lib(sandbox, build_dir, target, 'watchos', 'watchsimulator', configuration, PodBuilder::Configuration.deterministic_build, prebuilt_root_paths)
380
- else raise "\n\nUnknown platform '#{target.platform_name}'".red end
380
+ else raise "\n\nUnknown platform '#{target.platform_name}'\n".red end
381
381
 
382
382
  raise Pod::Informative, 'The build directory was not found in the expected location.' unless build_dir.directory?
383
383
 
@@ -436,7 +436,7 @@ Pod::HooksManager.register('podbuilder-rome', :post_install) do |installer_conte
436
436
  FileUtils.mv(dsym_source, sandbox_root.parent)
437
437
  end
438
438
  else
439
- raise "Not implemented"
439
+ raise "\n\nNot implemented\n".red
440
440
  end
441
441
  end
442
442
 
@@ -1,4 +1,4 @@
1
1
  module PodBuilder
2
- VERSION = "3.0.1"
2
+ VERSION = "3.1.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.0.1
4
+ version: 3.1.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-02-17 00:00:00.000000000 Z
11
+ date: 2021-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -233,7 +233,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
233
233
  - !ruby/object:Gem::Version
234
234
  version: '0'
235
235
  requirements: []
236
- rubygems_version: 3.1.2
236
+ rubygems_version: 3.0.3
237
237
  signing_key:
238
238
  specification_version: 4
239
239
  summary: Prebuild CocoaPods pods