pod-builder 1.9.4 → 2.0.0.beta.18

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.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +9 -0
  3. data/Example/Frameworks/.gitignore +6 -0
  4. data/Example/Frameworks/.pod_builder/pod_builder +0 -0
  5. data/Example/Frameworks/PodBuilder.json +10 -4
  6. data/Example/Frameworks/Podfile +23 -0
  7. data/Example/Frameworks/Podfile.restore +40 -0
  8. data/Example/PodBuilderExample/AppDelegate.swift +4 -0
  9. data/Example/PodBuilderExample.xcodeproj/project.pbxproj +3 -8
  10. data/Example/{PodBuilderExample.xcodeproj/xcuserdata/tomas.xcuserdatad/xcschemes/xcschememanagement.plist → PodBuilderExample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist} +2 -8
  11. data/Example/Podfile +44 -1
  12. data/Example/Podfile.lock +426 -7
  13. data/Example/Pods-acknowledgements.md +210 -0
  14. data/Example/Pods-acknowledgements.plist +206 -0
  15. data/README.md +38 -1
  16. data/exe/pod_builder +14 -14
  17. data/lib/pod_builder/analyze.rb +32 -7
  18. data/lib/pod_builder/analyzer.rb +16 -0
  19. data/lib/pod_builder/command/build.rb +110 -109
  20. data/lib/pod_builder/command/clean.rb +9 -11
  21. data/lib/pod_builder/command/clear_lldbinit.rb +1 -1
  22. data/lib/pod_builder/command/deintegrate.rb +2 -1
  23. data/lib/pod_builder/command/generate_lfs.rb +2 -2
  24. data/lib/pod_builder/command/install_sources.rb +1 -1
  25. data/lib/pod_builder/command/switch.rb +99 -99
  26. data/lib/pod_builder/command/sync_podfile.rb +2 -1
  27. data/lib/pod_builder/command/update.rb +1 -1
  28. data/lib/pod_builder/command/update_lldbinit.rb +2 -2
  29. data/lib/pod_builder/configuration.rb +61 -7
  30. data/lib/pod_builder/core.rb +60 -5
  31. data/lib/pod_builder/info.rb +24 -90
  32. data/lib/pod_builder/install.rb +148 -82
  33. data/lib/pod_builder/podfile/post_actions.rb +0 -1
  34. data/lib/pod_builder/podfile.rb +83 -14
  35. data/lib/pod_builder/podfile_item.rb +152 -74
  36. data/lib/pod_builder/podspec.rb +125 -133
  37. data/lib/pod_builder/rome/post_install.rb +248 -0
  38. data/lib/pod_builder/rome/pre_install.rb +6 -0
  39. data/lib/pod_builder/templates/build_podfile.template +1 -1
  40. data/lib/pod_builder/version.rb +1 -1
  41. data/pod-builder.gemspec +3 -3
  42. metadata +28 -60
  43. data/Example/Pods/Alamofire/LICENSE +0 -19
  44. data/Example/Pods/Alamofire/README.md +0 -242
  45. data/Example/Pods/Alamofire/Source/AFError.swift +0 -460
  46. data/Example/Pods/Alamofire/Source/Alamofire.swift +0 -465
  47. data/Example/Pods/Alamofire/Source/DispatchQueue+Alamofire.swift +0 -37
  48. data/Example/Pods/Alamofire/Source/MultipartFormData.swift +0 -580
  49. data/Example/Pods/Alamofire/Source/NetworkReachabilityManager.swift +0 -233
  50. data/Example/Pods/Alamofire/Source/Notifications.swift +0 -55
  51. data/Example/Pods/Alamofire/Source/ParameterEncoding.swift +0 -483
  52. data/Example/Pods/Alamofire/Source/Request.swift +0 -654
  53. data/Example/Pods/Alamofire/Source/Response.swift +0 -567
  54. data/Example/Pods/Alamofire/Source/ResponseSerialization.swift +0 -715
  55. data/Example/Pods/Alamofire/Source/Result.swift +0 -300
  56. data/Example/Pods/Alamofire/Source/ServerTrustPolicy.swift +0 -307
  57. data/Example/Pods/Alamofire/Source/SessionDelegate.swift +0 -725
  58. data/Example/Pods/Alamofire/Source/SessionManager.swift +0 -896
  59. data/Example/Pods/Alamofire/Source/TaskDelegate.swift +0 -466
  60. data/Example/Pods/Alamofire/Source/Timeline.swift +0 -136
  61. data/Example/Pods/Alamofire/Source/Validation.swift +0 -315
  62. data/Example/Pods/Manifest.lock +0 -16
  63. data/Example/Pods/Pods.xcodeproj/project.pbxproj +0 -673
  64. data/Example/Pods/Pods.xcodeproj/xcuserdata/tomas.xcuserdatad/xcschemes/Alamofire.xcscheme +0 -60
  65. data/Example/Pods/Pods.xcodeproj/xcuserdata/tomas.xcuserdatad/xcschemes/Pods-PodBuilderExample.xcscheme +0 -60
  66. data/Example/Pods/Pods.xcodeproj/xcuserdata/tomas.xcuserdatad/xcschemes/xcschememanagement.plist +0 -21
  67. data/Example/Pods/Target Support Files/Alamofire/Alamofire-dummy.m +0 -5
  68. data/Example/Pods/Target Support Files/Alamofire/Alamofire-prefix.pch +0 -12
  69. data/Example/Pods/Target Support Files/Alamofire/Alamofire-umbrella.h +0 -16
  70. data/Example/Pods/Target Support Files/Alamofire/Alamofire.modulemap +0 -6
  71. data/Example/Pods/Target Support Files/Alamofire/Alamofire.xcconfig +0 -9
  72. data/Example/Pods/Target Support Files/Alamofire/Info.plist +0 -26
  73. data/Example/Pods/Target Support Files/Pods-PodBuilderExample/Info.plist +0 -26
  74. data/Example/Pods/Target Support Files/Pods-PodBuilderExample/Pods-PodBuilderExample-acknowledgements.markdown +0 -26
  75. data/Example/Pods/Target Support Files/Pods-PodBuilderExample/Pods-PodBuilderExample-acknowledgements.plist +0 -58
  76. data/Example/Pods/Target Support Files/Pods-PodBuilderExample/Pods-PodBuilderExample-dummy.m +0 -5
  77. data/Example/Pods/Target Support Files/Pods-PodBuilderExample/Pods-PodBuilderExample-frameworks.sh +0 -153
  78. data/Example/Pods/Target Support Files/Pods-PodBuilderExample/Pods-PodBuilderExample-resources.sh +0 -118
  79. data/Example/Pods/Target Support Files/Pods-PodBuilderExample/Pods-PodBuilderExample-umbrella.h +0 -16
  80. data/Example/Pods/Target Support Files/Pods-PodBuilderExample/Pods-PodBuilderExample.debug.xcconfig +0 -11
  81. data/Example/Pods/Target Support Files/Pods-PodBuilderExample/Pods-PodBuilderExample.modulemap +0 -6
  82. data/Example/Pods/Target Support Files/Pods-PodBuilderExample/Pods-PodBuilderExample.release.xcconfig +0 -11
  83. data/lib/pod_builder/cocoapods/specification.rb +0 -27
@@ -1,41 +1,6 @@
1
1
  require 'cfpropertylist'
2
-
3
- # We swizzle the analyzer to inject spec overrides. This might no longer be needed
4
- # given that we're swizzling the Pod::Downloader as well
5
- class Pod::Specification::Linter::Analyzer
6
- alias_method :swz_analyze, :analyze
7
-
8
- def analyze(*args)
9
- spec = consumer.spec
10
- if overrides = PodBuilder::Configuration.spec_overrides[spec.name]
11
- overrides.each do |k, v|
12
- spec.attributes_hash[k] = v
13
- end
14
- end
15
-
16
- return swz_analyze
17
- end
18
- end
19
-
20
- Pod::Downloader.singleton_class.send(:alias_method, :swz_download, :download)
21
- module Pod::Downloader
22
- def self.download(
23
- request,
24
- target,
25
- can_cache: true,
26
- cache_path: Pod::Config.instance.cache_root + 'Pods'
27
- )
28
- result = swz_download(request, target)
29
-
30
- if overrides = PodBuilder::Configuration.spec_overrides[result.spec.name]
31
- overrides.each do |k, v|
32
- result.spec.attributes_hash[k] = v
33
- end
34
- end
35
-
36
- result
37
- end
38
- end
2
+ require 'digest'
3
+ require 'colored'
39
4
 
40
5
  # The Pod::Target and Pod::Installer::Xcode::PodTargetDependencyInstaller swizzles patch
41
6
  # the following issues:
@@ -44,6 +9,23 @@ end
44
9
  begin
45
10
  require 'cocoapods/installer/xcode/pods_project_generator/pod_target_dependency_installer.rb'
46
11
 
12
+ class Pod::Specification
13
+ Pod::Specification.singleton_class.send(:alias_method, :swz_from_hash, :from_hash)
14
+ Pod::Specification.singleton_class.send(:alias_method, :swz_from_string, :from_string)
15
+
16
+ def self.from_string(*args)
17
+ spec = swz_from_string(*args)
18
+
19
+ if overrides = PodBuilder::Configuration.spec_overrides[spec.name]
20
+ overrides.each do |k, v|
21
+ spec.attributes_hash[k] = v
22
+ end
23
+ end
24
+
25
+ spec
26
+ end
27
+ end
28
+
47
29
  class Pod::Target
48
30
  attr_accessor :mock_dynamic_framework
49
31
 
@@ -64,6 +46,19 @@ begin
64
46
  end
65
47
  end
66
48
 
49
+ # Starting from CocoaPods 1.10.0 and later resources are no longer copied inside the .framework
50
+ # when building static frameworks. While this is correct when using CP normally, for redistributable
51
+ # frameworks we require resources to be shipped along the binary
52
+ class Pod::Installer::Xcode::PodsProjectGenerator::PodTargetInstaller
53
+ alias_method :swz_add_files_to_build_phases, :add_files_to_build_phases
54
+
55
+ def add_files_to_build_phases(native_target, test_native_targets, app_native_targets)
56
+ target.mock_dynamic_framework = target.build_as_static_framework?
57
+ swz_add_files_to_build_phases(native_target, test_native_targets, app_native_targets)
58
+ target.mock_dynamic_framework = false
59
+ end
60
+ end
61
+
67
62
  class Pod::Installer::Xcode::PodTargetDependencyInstaller
68
63
  alias_method :swz_wire_resource_bundle_targets, :wire_resource_bundle_targets
69
64
 
@@ -81,6 +76,8 @@ end
81
76
  module PodBuilder
82
77
  class Install
83
78
  def self.podfile(podfile_content, podfile_items, build_configuration)
79
+ puts "Preparing build Podfile".yellow
80
+
84
81
  PodBuilder::safe_rm_rf(Configuration.build_path)
85
82
  FileUtils.mkdir_p(Configuration.build_path)
86
83
 
@@ -96,7 +93,7 @@ module PodBuilder
96
93
  end
97
94
 
98
95
  # It is important that CocoaPods compiles the files under Configuration.build_path in order that DWARF
99
- # debug info reference to this path. Doing otherwise breaks the assumptions that make the `update_lldbinit`
96
+ # debug info reference to this path. Doing otherwise breaks the assumptions that makes the `update_lldbinit`
100
97
  # command work
101
98
  podfile_content.gsub!("'#{podfile_item.path}'", "'#{destination_path}'")
102
99
 
@@ -113,39 +110,89 @@ module PodBuilder
113
110
  begin
114
111
  lock_file = "#{Configuration.build_path}/pod_builder.lock"
115
112
  FileUtils.touch(lock_file)
113
+
114
+ framework_build_hashes = Hash.new
115
+ if !OPTIONS.has_key?(:force_rebuild)
116
+ download # Copy files under #{Configuration.build_path}/Pods so that we can determine build folder hashes
117
+
118
+ # Replace prebuilt entries in Podfile for Pods that have no changes in source code which will avoid rebuilding them
119
+ items = podfile_items.group_by { |t| t.root_name }.map { |k, v| v.first } # Return one podfile_item per root_name
120
+ items.each do |item|
121
+ framework_path = File.join(PodBuilder::prebuiltpath, "#{item.module_name}.framework")
122
+ podspec_path = File.join(PodBuilder::prebuiltpath, "#{item.root_name}.podspec")
123
+ if (last_build_folder_hash = build_folder_hash_in_framework_plist_info(framework_path)) && File.exist?(podspec_path)
124
+ if last_build_folder_hash == build_folder_hash(item)
125
+ puts "No changes detected to '#{item.root_name}', will skip rebuild".blue
126
+ podfile_items.select { |t| t.root_name == item.root_name }.each do |replace_item|
127
+ replace_regex = "pod '#{Regexp.quote(replace_item.name)}', .*"
128
+ replace_line_found = podfile_content =~ /#{replace_regex}/i
129
+ raise "Failed finding pod entry for '#{replace_item.name}'" unless replace_line_found
130
+ podfile_content.gsub!(/#{replace_regex}/, replace_item.prebuilt_entry(true, true))
131
+ end
132
+ end
133
+ end
134
+ end
135
+
136
+ File.write(podfile_path, podfile_content)
137
+ end
116
138
 
117
139
  install
118
140
 
119
141
  add_framework_plist_info(podfile_items)
120
- cleanup_frameworks(podfile_items)
142
+ cleanup_frameworks(podfile_items)
121
143
  copy_frameworks(podfile_items)
122
144
  copy_libraries(podfile_items)
123
- if build_configuration != "debug"
124
- copy_dsyms(podfile_items)
125
- end
145
+ copy_dsyms(podfile_items)
126
146
  rescue Exception => e
127
147
  raise e
128
148
  ensure
129
149
  FileUtils.rm(lock_file)
150
+
151
+ if !OPTIONS.has_key?(:debug)
152
+ PodBuilder::safe_rm_rf(Configuration.build_path)
153
+ end
130
154
  end
131
155
  end
132
156
 
133
157
  private
134
158
 
135
159
  def self.install
160
+ puts "Building frameworks".yellow
161
+
136
162
  CLAide::Command::PluginManager.load_plugins("cocoapods")
137
163
 
138
- current_dir = Dir.pwd
139
-
140
- Dir.chdir(Configuration.build_path)
164
+ Dir.chdir(Configuration.build_path) do
165
+ config = Pod::Config.new()
166
+ installer = Pod::Installer.new(config.sandbox, config.podfile, config.lockfile)
167
+ installer.repo_update = false
168
+ installer.update = false
169
+
170
+ install_start_time = Time.now
171
+ installer.install!
172
+ install_time = Time.now - install_start_time
141
173
 
142
- config = Pod::Config.new()
143
- installer = Pod::Installer.new(config.sandbox, config.podfile, config.lockfile)
144
- installer.repo_update = false
145
- installer.update = false
146
- installer.install!
174
+ puts "Build completed in #{install_time.to_i} seconds".blue
175
+ end
176
+ end
147
177
 
148
- Dir.chdir(current_dir)
178
+ def self.download
179
+ puts "Downloading Pods source code".yellow
180
+
181
+ CLAide::Command::PluginManager.load_plugins("cocoapods")
182
+
183
+ Dir.chdir(Configuration.build_path) do
184
+ Pod::UserInterface::config.silent = true
185
+
186
+ config = Pod::Config.new()
187
+ installer = Pod::Installer.new(config.sandbox, config.podfile, config.lockfile)
188
+ installer.repo_update = false
189
+ installer.update = false
190
+ installer.prepare
191
+ installer.resolve_dependencies
192
+ installer.download_dependencies
193
+
194
+ Pod::UserInterface::config.silent = false
195
+ end
149
196
  end
150
197
 
151
198
  def self.rel_path(path, podfile_items)
@@ -160,12 +207,12 @@ module PodBuilder
160
207
 
161
208
  def self.add_framework_plist_info(podfile_items)
162
209
  swift_version = PodBuilder::system_swift_version
163
- Dir.glob("#{Configuration.build_path}/Rome/*.framework") do |framework_path|
210
+ Dir.glob(PodBuilder::buildpath_prebuiltpath("*.framework")) do |framework_path|
164
211
  filename_ext = File.basename(framework_path)
165
212
  filename = File.basename(framework_path, ".*")
166
213
 
167
214
  specs = podfile_items.select { |x| x.module_name == filename }
168
- specs += podfile_items.select { |x| x.vendored_items.map { |x| File.basename(x) }.include?(filename_ext) }
215
+ specs += podfile_items.select { |x| x.vendored_frameworks.map { |x| File.basename(x) }.include?(filename_ext) }
169
216
  if podfile_item = specs.first
170
217
  podbuilder_file = File.join(framework_path, Configuration.framework_plist_filename)
171
218
  entry = podfile_item.entry(true, false)
@@ -182,6 +229,7 @@ module PodBuilder
182
229
  plist_data['specs'] = (specs.map(&:name) + subspec_self_deps).uniq
183
230
  plist_data['is_static'] = podfile_item.is_static
184
231
  plist_data['original_compile_path'] = Pathname.new(Configuration.build_path).realpath.to_s
232
+ plist_data['build_folder_hash'] = build_folder_hash(podfile_item)
185
233
 
186
234
  plist.value = CFPropertyList.guess(plist_data)
187
235
  plist.save(podbuilder_file, CFPropertyList::List::FORMAT_BINARY)
@@ -192,28 +240,29 @@ module PodBuilder
192
240
  end
193
241
 
194
242
  def self.cleanup_frameworks(podfile_items)
195
- Dir.glob("#{Configuration.build_path}/Rome/*.framework") do |framework_path|
243
+ Dir.glob(PodBuilder::buildpath_prebuiltpath("*.framework")) do |framework_path|
196
244
  framework_rel_path = rel_path(framework_path, podfile_items)
197
245
  dsym_path = framework_rel_path + ".dSYM"
198
246
 
199
- PodBuilder::safe_rm_rf(PodBuilder::basepath("Rome/#{framework_rel_path}"))
200
- PodBuilder::safe_rm_rf(PodBuilder::basepath("dSYM/iphoneos/#{dsym_path}"))
201
- PodBuilder::safe_rm_rf(PodBuilder::basepath("dSYM/iphonesimulator/#{dsym_path}"))
247
+ PodBuilder::safe_rm_rf(PodBuilder::prebuiltpath(framework_rel_path))
248
+ Configuration.supported_platforms.each do |platform|
249
+ PodBuilder::safe_rm_rf(PodBuilder::dsympath("#{platform}/#{dsym_path}"))
250
+ end
202
251
  end
203
252
  end
204
253
 
205
254
  def self.copy_frameworks(podfile_items)
206
- Dir.glob("#{Configuration.build_path}/Rome/*.framework") do |framework_path|
255
+ Dir.glob(PodBuilder::buildpath_prebuiltpath("*.framework")) do |framework_path|
207
256
  framework_rel_path = rel_path(framework_path, podfile_items)
208
257
 
209
- destination_path = PodBuilder::basepath("Rome/#{framework_rel_path}")
258
+ destination_path = PodBuilder::prebuiltpath(framework_rel_path)
210
259
  FileUtils.mkdir_p(File.dirname(destination_path))
211
260
  FileUtils.cp_r(framework_path, destination_path)
212
261
  end
213
262
  end
214
263
 
215
264
  def self.copy_libraries(podfile_items)
216
- Dir.glob("#{Configuration.build_path}/Rome/*.a") do |library_path|
265
+ Dir.glob(PodBuilder::buildpath_prebuiltpath("*.a")) do |library_path|
217
266
  library_name = File.basename(library_path)
218
267
 
219
268
  # Find vendored libraries in the build folder:
@@ -226,11 +275,7 @@ module PodBuilder
226
275
  next
227
276
  end
228
277
 
229
- podfile_item.vendored_items.each do |vendored_item|
230
- unless vendored_item.end_with?(".a")
231
- next
232
- end
233
-
278
+ podfile_item.vendored_libraries.each do |vendored_item|
234
279
  if result = Dir.glob("#{search_base}**/#{vendored_item}").first
235
280
  result_path = result.gsub(search_base, "")
236
281
  module_name = result_path.split("/").first
@@ -239,7 +284,7 @@ module PodBuilder
239
284
 
240
285
  result_path = result_path.split("/").drop(1).join("/")
241
286
 
242
- destination_path = PodBuilder::basepath("Rome/#{library_rel_path}/#{result_path}")
287
+ destination_path = PodBuilder::prebuiltpath("#{library_rel_path}/#{result_path}")
243
288
  FileUtils.mkdir_p(File.dirname(destination_path))
244
289
  FileUtils.cp_r(library_path, destination_path, :remove_destination => true)
245
290
  end
@@ -247,7 +292,7 @@ module PodBuilder
247
292
  end
248
293
 
249
294
  # A pod might depend upon a static library that is shipped with a prebuilt framework
250
- # which is not added to the Rome folder and the PodBuilder.podspec
295
+ # which is not added to the Rome folder and podspecs
251
296
  #
252
297
  # An example is Google-Mobile-Ads-SDK which adds
253
298
  # - vendored framework: GooleMobileAds.framework
@@ -261,7 +306,7 @@ module PodBuilder
261
306
 
262
307
  result_path = result_path.split("/").drop(1).join("/")
263
308
 
264
- destination_path = PodBuilder::basepath("Rome/#{library_rel_path}/#{result_path}")
309
+ destination_path = PodBuilder::prebuiltpath("#{library_rel_path}/#{result_path}")
265
310
  FileUtils.mkdir_p(File.dirname(destination_path))
266
311
  FileUtils.cp_r(library_path, destination_path)
267
312
  end
@@ -271,20 +316,14 @@ module PodBuilder
271
316
  end
272
317
 
273
318
  def self.copy_dsyms(podfile_items)
274
- Dir.glob("#{Configuration.build_path}/dSYM/*iphoneos/**/*.dSYM") do |dsym_path|
275
- framework_rel_path = rel_path(dsym_path.gsub(File.extname(dsym_path), ""), podfile_items)
276
-
277
- destination_path = PodBuilder::basepath("dSYM/iphoneos/#{File.dirname(framework_rel_path)}")
278
- FileUtils.mkdir_p(destination_path)
279
- FileUtils.cp_r(dsym_path, destination_path)
280
- end
281
-
282
- Dir.glob("#{Configuration.build_path}/dSYM/*iphonesimulator/**/*.dSYM") do |dsym_path|
283
- framework_rel_path = rel_path(dsym_path.gsub(File.extname(dsym_path), ""), podfile_items)
284
-
285
- destination_path = PodBuilder::basepath("dSYM/iphonesimulator/#{File.dirname(framework_rel_path)}")
286
- FileUtils.mkdir_p(destination_path)
287
- FileUtils.cp_r(dsym_path, destination_path)
319
+ Configuration.supported_platforms.each do |platform|
320
+ Dir.glob("#{Configuration.build_path}/dSYM/#{platform}/**/*.dSYM") do |dsym_path|
321
+ framework_rel_path = rel_path(dsym_path.gsub(File.extname(dsym_path), ""), podfile_items)
322
+
323
+ destination_path = PodBuilder::dsympath("#{platform}/#{File.dirname(framework_rel_path)}")
324
+ FileUtils.mkdir_p(destination_path)
325
+ FileUtils.cp_r(dsym_path, destination_path)
326
+ end
288
327
  end
289
328
  end
290
329
 
@@ -295,5 +334,32 @@ module PodBuilder
295
334
  system("git init")
296
335
  Dir.chdir(current_dir)
297
336
  end
337
+
338
+ def self.build_folder_hash_in_framework_plist_info(framework_path)
339
+ podbuilder_file = File.join(framework_path, Configuration.framework_plist_filename)
340
+
341
+ unless File.exist?(podbuilder_file)
342
+ return nil
343
+ end
344
+
345
+ plist = CFPropertyList::List.new(:file => podbuilder_file)
346
+ data = CFPropertyList.native_types(plist.value)
347
+
348
+ return data['build_folder_hash']
349
+ end
350
+
351
+ def self.build_folder_hash(podfile_item)
352
+ if podfile_item.is_development_pod
353
+ if Pathname.new(podfile_item.path).absolute?
354
+ item_path = podfile_item.path
355
+ else
356
+ item_path = PodBuilder::basepath(podfile_item.path)
357
+ end
358
+ else
359
+ item_path = "#{Configuration.build_path}/Pods/#{podfile_item.root_name}"
360
+ end
361
+
362
+ return `find '#{item_path}' -type f -print0 | sort -z | xargs -0 sha1sum | sha1sum | cut -d' ' -f1`.strip()
363
+ end
298
364
  end
299
365
  end
@@ -1,4 +1,3 @@
1
- require 'colored'
2
1
  require 'xcodeproj'
3
2
  require 'pod_builder/core'
4
3
 
@@ -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) {}"].freeze
7
7
  private_constant :PRE_INSTALL_ACTIONS
8
8
 
9
- def self.from_podfile_items(items, analyzer)
9
+ def self.from_podfile_items(items, analyzer, build_configuration)
10
10
  raise "no items" unless items.count > 0
11
11
 
12
12
  sources = analyzer.sources
@@ -20,9 +20,7 @@ module PodBuilder
20
20
 
21
21
  podfile.sub!("%%%sources%%%", sources.map { |x| "source '#{x.url}'" }.join("\n"))
22
22
 
23
- build_configurations = items.map(&:build_configuration).uniq
24
- raise "Found different build configurations in #{items}" if build_configurations.count != 1
25
- podfile.sub!("%%%build_configuration%%%", build_configurations.first.capitalize)
23
+ podfile.sub!("%%%build_configuration%%%", build_configuration.capitalize)
26
24
 
27
25
  podfile_build_settings = ""
28
26
 
@@ -35,12 +33,25 @@ module PodBuilder
35
33
 
36
34
  # These settings need to be set as is to properly build frameworks
37
35
  build_settings['SWIFT_COMPILATION_MODE'] = 'wholemodule'
38
- build_settings['CLANG_ENABLE_MODULE_DEBUGGING'] = 'NO'
39
36
  build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
40
37
  build_settings['DEBUG_INFORMATION_FORMAT'] = "dwarf-with-dsym"
41
38
 
39
+ build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = platform.deployment_target.version # Fix compilation warnings on Xcode 12
40
+
41
+ # Don't store .pcm info in binary, see https://forums.swift.org/t/swift-behavior-of-gmodules-and-dsyms/23211/3
42
+ build_settings['CLANG_ENABLE_MODULE_DEBUGGING'] = 'NO'
43
+ build_settings['OTHER_SWIFT_FLAGS'] = "-Xfrontend -no-clang-module-breadcrumbs"
44
+
45
+ # Improve compile speed
46
+ build_settings['COMPILER_INDEX_STORE_ENABLE'] = 'NO'
47
+ build_settings['SWIFT_INDEX_STORE_ENABLE'] = 'NO'
48
+ build_settings['MTL_ENABLE_INDEX_STORE'] = 'NO'
49
+
42
50
  if Configuration.build_system == "Legacy"
43
51
  build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = "NO"
52
+ raise "\n\nCan't enable library evolution support with legacy build system!" if Configuration.library_evolution_support
53
+ elsif Configuration.library_evolution_support
54
+ build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = "YES"
44
55
  end
45
56
 
46
57
  build_settings['SWIFT_VERSION'] = item_build_settings["SWIFT_VERSION"] || item.swift_version || project_swift_version(analyzer)
@@ -55,7 +66,7 @@ module PodBuilder
55
66
  if x.split("/").first == item.root_name
56
67
  next nil # remove dependency to parent spec
57
68
  end
58
- if overridded_module_name = Configuration.spec_overrides.fetch(x, {})["module_name"]
69
+ if overridded_module_name = Configuration.spec_overrides.fetch(x, {})["module_name"] # this might no longer be needed after
59
70
  next overridded_module_name
60
71
  end
61
72
  }.compact
@@ -104,9 +115,6 @@ module PodBuilder
104
115
  }
105
116
  end
106
117
 
107
- multiple_buildable_items = podfile_items.uniq { |t| t.root_name }
108
- buildable_items = podfile_items.reject { |t| multiple_buildable_items.map(&:root_name).include?(t.root_name) && t.is_external == false }
109
-
110
118
  result_targets = analyzer.instance_variable_get("@result").targets.map(&:name)
111
119
  podfile_content = ["# Autogenerated by PodBuilder (https://github.com/Subito-it/PodBuilder)", "# Please don't modify this file", "\n"]
112
120
  podfile_content += analyzer.podfile.sources.map { |x| "source '#{x}'" }
@@ -132,7 +140,7 @@ module PodBuilder
132
140
 
133
141
  specifications.each do |spec|
134
142
  item = podfile_items.detect { |x| x.name == spec.name }
135
- if buildable_items.map(&:name).include?(spec.name)
143
+ if podfile_items.map(&:name).include?(spec.name)
136
144
  podfile_content.push("\t#{item.entry}")
137
145
  end
138
146
  end
@@ -146,6 +154,9 @@ module PodBuilder
146
154
  def self.write_prebuilt(all_buildable_items, analyzer)
147
155
  puts "Updating Application Podfile".yellow
148
156
 
157
+ explicit_deps = analyzer.explicit_pods()
158
+ explicit_deps.map! { |t| all_buildable_items.detect { |x| x.name == t.name } }
159
+ explicit_deps.uniq!
149
160
  podbuilder_podfile_path = PodBuilder::basepath("Podfile")
150
161
  rel_path = Pathname.new(podbuilder_podfile_path).relative_path_from(Pathname.new(PodBuilder::project_path)).to_s
151
162
 
@@ -162,18 +173,41 @@ module PodBuilder
162
173
 
163
174
  if pod_name = pod_definition_in(line, true)
164
175
  if podfile_item = all_buildable_items.detect { |x| x.name == pod_name }
165
- if Podspec.include?(podfile_item.name)
176
+ if Podspec.include?(podfile_item.root_name)
166
177
  if podfile_item.vendored_framework_path.nil?
167
178
  marker = podfile_item.prebuilt_marker()
168
179
 
169
180
  podfile_item_dependency_items = all_buildable_items.select { |x| podfile_item.dependency_names.include?(x.name) && x.vendored_framework_path.nil? == false }
170
181
  if podfile_item_dependency_items.count > 0
171
- prebuilt_lines += podfile_item_dependency_items.map { |x| "#{line.detect_indentation}#{x.prebuilt_entry(include_pb_entry = false)}#{marker}\n" }.uniq
182
+ prebuilt_lines += podfile_item_dependency_items.map { |x| "#{line.detect_indentation}#{x.prebuilt_entry(false)}#{marker}\n" }.uniq
172
183
  else
173
184
  prebuilt_lines.push(line)
174
185
  end
175
186
  else
176
187
  prebuilt_lines.push("#{line.detect_indentation}#{podfile_item.prebuilt_entry}\n")
188
+
189
+ marker = podfile_item.prebuilt_marker()
190
+ non_explicit_dependencies = podfile_item.recursive_dependencies(all_buildable_items) - explicit_deps
191
+ non_explicit_dependencies_root_names = non_explicit_dependencies.map(&:root_name).uniq.filter { |t| t != podfile_item.root_name }
192
+ non_explicit_dependencies = non_explicit_dependencies_root_names.map { |x|
193
+ if item = all_buildable_items.detect { |t| x == t.name }
194
+ item
195
+ else
196
+ item = all_buildable_items.detect { |t| x == t.root_name }
197
+ end
198
+ }.compact
199
+
200
+ non_explicit_dependencies.each do |dep|
201
+ dep_item = all_buildable_items.detect { |x| x.name == dep.name }
202
+
203
+ if Podspec.include?(dep_item.root_name)
204
+ pod_name = dep_item.prebuilt_entry(false)
205
+ pod_name.gsub!(dep.name, dep.root_name)
206
+ prebuilt_lines.push("#{line.detect_indentation}#{pod_name}#{marker}\n")
207
+ end
208
+
209
+ explicit_deps.push(dep)
210
+ end
177
211
  end
178
212
 
179
213
  next
@@ -197,7 +231,8 @@ module PodBuilder
197
231
  puts "Running pod install".yellow
198
232
 
199
233
  Dir.chdir(PodBuilder::project_path) do
200
- system("pod install;")
234
+ bundler_prefix = Configuration.use_bundler ? "bundle exec " : ""
235
+ system("#{bundler_prefix}pod install;")
201
236
  end
202
237
  end
203
238
 
@@ -253,6 +288,8 @@ module PodBuilder
253
288
  return nil
254
289
  end
255
290
 
291
+ puts "Checking Podfile.restore".yellow
292
+
256
293
  podfile_restore_path = PodBuilder::basepath("Podfile.restore")
257
294
  unless File.exist?(podfile_restore_path)
258
295
  return
@@ -298,6 +335,38 @@ module PodBuilder
298
335
  end
299
336
  end
300
337
 
338
+ def self.resolve_pod_names(names, all_buildable_items)
339
+ resolved_names = []
340
+
341
+ names.each do |name|
342
+ if item = all_buildable_items.detect { |t| t.root_name.downcase == name.downcase }
343
+ resolved_names.push(item.root_name)
344
+ end
345
+ end
346
+
347
+ return resolved_names.uniq
348
+ end
349
+
350
+ def self.resolve_pod_names_from_podfile(names)
351
+ resolved_names = []
352
+
353
+ # resolve potentially wrong pod name case
354
+ podfile_path = PodBuilder::basepath("Podfile")
355
+ content = File.read(podfile_path)
356
+
357
+ current_section = ""
358
+ content.each_line do |line|
359
+ matches = line.gsub("\"", "'").match(/pod '(.*?)'/)
360
+ if matches&.size == 2
361
+ if resolved_name = names.detect { |t| matches[1].split("/").first.downcase == t.downcase }
362
+ resolved_names.push(matches[1].split("/").first)
363
+ end
364
+ end
365
+ end
366
+
367
+ resolved_names.uniq
368
+ end
369
+
301
370
  private
302
371
 
303
372
  def self.indentation_from_file(path)
@@ -410,7 +479,7 @@ module PodBuilder
410
479
  path = matches[6]
411
480
 
412
481
  is_absolute = ["~", "/"].include?(path[0])
413
- unless !pod_name.start_with?("PodBuilder/") && !is_absolute
482
+ unless !PodBuilder::prebuiltpath.end_with?(path) && !is_absolute
414
483
  podfile_lines.push(line)
415
484
  next
416
485
  end