cocoapods-xzpackager 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +7 -0
  2. data/.coveralls.yml +1 -0
  3. data/.gitignore +3 -0
  4. data/.rubocop-cocoapods.yml +71 -0
  5. data/.rubocop.yml +38 -0
  6. data/.travis.yml +9 -0
  7. data/Gemfile +12 -0
  8. data/Gemfile.lock +121 -0
  9. data/LICENSE +22 -0
  10. data/README.md +42 -0
  11. data/Rakefile +12 -0
  12. data/TAGS +180 -0
  13. data/cocoapods-xzpackager.gemspec +22 -0
  14. data/lib/cocoapods-packager/builder.rb +335 -0
  15. data/lib/cocoapods-packager/framework.rb +75 -0
  16. data/lib/cocoapods-packager/mangle.rb +32 -0
  17. data/lib/cocoapods-packager/pod_utils.rb +244 -0
  18. data/lib/cocoapods-packager/spec_builder.rb +219 -0
  19. data/lib/cocoapods-packager/symbols.rb +42 -0
  20. data/lib/cocoapods-packager/user_interface/build_failed_report.rb +15 -0
  21. data/lib/cocoapods_plugin.rb +8 -0
  22. data/lib/cocoapods_xzpackager.rb +5 -0
  23. data/lib/pod/command/package.rb +226 -0
  24. data/scripts/lstconst.sh +9 -0
  25. data/scripts/lstsym.sh +8 -0
  26. data/spec/command/error_spec.rb +74 -0
  27. data/spec/command/package_spec.rb +359 -0
  28. data/spec/command/subspecs_spec.rb +30 -0
  29. data/spec/fixtures/Builder.podspec +25 -0
  30. data/spec/fixtures/CPDColors.podspec +19 -0
  31. data/spec/fixtures/FH.podspec +18 -0
  32. data/spec/fixtures/KFData.podspec +73 -0
  33. data/spec/fixtures/LibraryConsumerDemo/.gitignore +22 -0
  34. data/spec/fixtures/LibraryConsumerDemo/LibraryConsumer.xcodeproj/project.pbxproj +340 -0
  35. data/spec/fixtures/LibraryConsumerDemo/LibraryConsumer.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  36. data/spec/fixtures/LibraryConsumerDemo/LibraryConsumer.xcodeproj/xcshareddata/xcschemes/LibraryConsumer.xcscheme +100 -0
  37. data/spec/fixtures/LibraryConsumerDemo/LibraryConsumer/AppDelegate.h +17 -0
  38. data/spec/fixtures/LibraryConsumerDemo/LibraryConsumer/AppDelegate.m +27 -0
  39. data/spec/fixtures/LibraryConsumerDemo/LibraryConsumer/Info.plist +40 -0
  40. data/spec/fixtures/LibraryConsumerDemo/LibraryConsumer/main.m +16 -0
  41. data/spec/fixtures/LibraryConsumerDemo/Podfile +5 -0
  42. data/spec/fixtures/LibraryDemo.podspec +14 -0
  43. data/spec/fixtures/NikeKit.podspec +19 -0
  44. data/spec/fixtures/OpenSans.podspec +18 -0
  45. data/spec/fixtures/PackagerTest/.gitignore +21 -0
  46. data/spec/fixtures/PackagerTest/PackagerTest.xcodeproj/project.pbxproj +536 -0
  47. data/spec/fixtures/PackagerTest/PackagerTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  48. data/spec/fixtures/PackagerTest/PackagerTest.xcodeproj/xcshareddata/xcschemes/PackagerTest.xcscheme +110 -0
  49. data/spec/fixtures/PackagerTest/PackagerTest.xcworkspace/contents.xcworkspacedata +1 -0
  50. data/spec/fixtures/PackagerTest/PackagerTest/CPDAppDelegate.h +15 -0
  51. data/spec/fixtures/PackagerTest/PackagerTest/CPDAppDelegate.m +49 -0
  52. data/spec/fixtures/PackagerTest/PackagerTest/Images.xcassets/AppIcon.appiconset/Contents.json +23 -0
  53. data/spec/fixtures/PackagerTest/PackagerTest/Images.xcassets/LaunchImage.launchimage/Contents.json +23 -0
  54. data/spec/fixtures/PackagerTest/PackagerTest/PackagerTest-Info.plist +38 -0
  55. data/spec/fixtures/PackagerTest/PackagerTest/PackagerTest-Prefix.pch +16 -0
  56. data/spec/fixtures/PackagerTest/PackagerTest/en.lproj/InfoPlist.strings +2 -0
  57. data/spec/fixtures/PackagerTest/PackagerTest/main.m +18 -0
  58. data/spec/fixtures/PackagerTest/PackagerTestTests/PackagerTestTests-Info.plist +22 -0
  59. data/spec/fixtures/PackagerTest/PackagerTestTests/PackagerTestTests.m +34 -0
  60. data/spec/fixtures/PackagerTest/PackagerTestTests/en.lproj/InfoPlist.strings +2 -0
  61. data/spec/fixtures/PackagerTest/Podfile +10 -0
  62. data/spec/fixtures/PackagerTest/Podfile.lock +32 -0
  63. data/spec/fixtures/Weakly.podspec +13 -0
  64. data/spec/fixtures/a.podspec +19 -0
  65. data/spec/fixtures/foo-bar.podspec +19 -0
  66. data/spec/fixtures/layer-client-messaging-schema.podspec +13 -0
  67. data/spec/integration/project_spec.rb +70 -0
  68. data/spec/pod/utils_spec.rb +58 -0
  69. data/spec/spec_helper.rb +50 -0
  70. data/spec/specification/builder_spec.rb +40 -0
  71. data/spec/specification/spec_builder_spec.rb +61 -0
  72. data/spec/user_interface/build_failed_report_spec.rb +11 -0
  73. metadata +225 -0
@@ -0,0 +1,22 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'cocoapods_xzpackager.rb'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'cocoapods-xzpackager'
8
+ spec.version = Pod::Packager::VERSION
9
+ spec.authors = ['Kyle Fuller', 'Boris Bügling','lsh']
10
+ spec.summary = 'CocoaPods plugin which allows you to generate a framework or static library from a podspec.'
11
+ spec.homepage = 'https://github.com/CocoaPods/cocoapods-packager'
12
+ spec.license = 'MIT'
13
+ spec.files = `git ls-files`.split($/)
14
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
15
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
16
+ spec.require_paths = ["lib"]
17
+
18
+ spec.add_dependency "cocoapods", '>= 1.1.1', '< 2.0'
19
+ spec.add_dependency "net-sftp"
20
+ spec.add_development_dependency "bundler", "~> 1.3"
21
+ spec.add_development_dependency "rake"
22
+ end
@@ -0,0 +1,335 @@
1
+ module Pod
2
+ class Builder
3
+ def initialize(platform, static_installer, source_dir, static_sandbox_root, dynamic_sandbox_root, public_headers_root, spec, embedded, mangle, dynamic, config, bundle_identifier, exclude_deps)
4
+ @platform = platform
5
+ @static_installer = static_installer
6
+ @source_dir = source_dir
7
+ @static_sandbox_root = static_sandbox_root
8
+ @dynamic_sandbox_root = dynamic_sandbox_root
9
+ @public_headers_root = public_headers_root
10
+ @spec = spec
11
+ @embedded = embedded
12
+ @mangle = mangle
13
+ @dynamic = dynamic
14
+ @config = config
15
+ @bundle_identifier = bundle_identifier
16
+ @exclude_deps = exclude_deps
17
+
18
+ @file_accessors = @static_installer.pod_targets.select { |t| t.pod_name == @spec.name }.flat_map(&:file_accessors)
19
+ end
20
+
21
+ def build(package_type)
22
+ case package_type
23
+ when :static_library
24
+ build_static_library
25
+ when :static_framework
26
+ build_static_framework
27
+ when :dynamic_framework
28
+ build_dynamic_framework
29
+ end
30
+ end
31
+
32
+ def build_static_library
33
+ UI.puts("Building static library #{@spec} with configuration #{@config}")
34
+
35
+ defines = compile
36
+ build_sim_libraries(defines)
37
+
38
+ platform_path = Pathname.new(@platform.name.to_s)
39
+ platform_path.mkdir unless platform_path.exist?
40
+
41
+ output = platform_path + "lib#{@spec.name}.a"
42
+
43
+ if @platform.name == :ios
44
+ build_static_library_for_ios(output)
45
+ else
46
+ build_static_library_for_mac(output)
47
+ end
48
+ end
49
+
50
+ def build_static_framework
51
+ UI.puts("Building static framework #{@spec} with configuration #{@config}")
52
+
53
+ defines = compile
54
+ build_sim_libraries(defines)
55
+
56
+ create_framework
57
+ output = @fwk.versions_path + Pathname.new(@spec.name)
58
+
59
+ if @platform.name == :ios
60
+ build_static_library_for_ios(output)
61
+ else
62
+ build_static_library_for_mac(output)
63
+ end
64
+
65
+ copy_headers
66
+ copy_license
67
+ copy_resources
68
+ @fwk.process_static_framework
69
+ end
70
+
71
+ def link_embedded_resources
72
+ target_path = @fwk.root_path + Pathname.new('Resources')
73
+ target_path.mkdir unless target_path.exist?
74
+
75
+ Dir.glob(@fwk.resources_path.to_s + '/*').each do |resource|
76
+ resource = Pathname.new(resource).relative_path_from(target_path)
77
+ `ln -sf #{resource} #{target_path}`
78
+ end
79
+ end
80
+
81
+ def build_dynamic_framework
82
+ UI.puts("Building dynamic framework #{@spec} with configuration #{@config}")
83
+
84
+ defines = compile
85
+ build_sim_libraries(defines)
86
+
87
+ if @bundle_identifier
88
+ defines = "#{defines} PRODUCT_BUNDLE_IDENTIFIER='#{@bundle_identifier}'"
89
+ end
90
+
91
+ output = "#{@dynamic_sandbox_root}/build/#{@spec.name}.framework/#{@spec.name}"
92
+
93
+ clean_directory_for_dynamic_build
94
+ if @platform.name == :ios
95
+ build_dynamic_framework_for_ios(defines, output)
96
+ else
97
+ build_dynamic_framework_for_mac(defines, output)
98
+ end
99
+
100
+ copy_resources
101
+ end
102
+
103
+ def build_dynamic_framework_for_ios(defines, output)
104
+ # Specify frameworks to link and search paths
105
+ linker_flags = static_linker_flags_in_sandbox
106
+ defines = "#{defines} OTHER_LDFLAGS='$(inherited) #{linker_flags.join(' ')}'"
107
+
108
+ # Build Target Dynamic Framework for both device and Simulator
109
+ device_defines = "#{defines} LIBRARY_SEARCH_PATHS=\"#{Dir.pwd}/#{@static_sandbox_root}/build\""
110
+ device_options = ios_build_options << ' -sdk iphoneos'
111
+ xcodebuild(device_defines, device_options, 'build', @spec.name.to_s, @dynamic_sandbox_root.to_s)
112
+
113
+ sim_defines = "#{defines} LIBRARY_SEARCH_PATHS=\"#{Dir.pwd}/#{@static_sandbox_root}/build-sim\" ONLY_ACTIVE_ARCH=NO"
114
+ xcodebuild(sim_defines, '-sdk iphonesimulator', 'build-sim', @spec.name.to_s, @dynamic_sandbox_root.to_s)
115
+
116
+ # Combine architectures
117
+ `lipo #{@dynamic_sandbox_root}/build/#{@spec.name}.framework/#{@spec.name} #{@dynamic_sandbox_root}/build-sim/#{@spec.name}.framework/#{@spec.name} -create -output #{output}`
118
+
119
+ FileUtils.mkdir(@platform.name.to_s)
120
+ `mv #{@dynamic_sandbox_root}/build/#{@spec.name}.framework #{@platform.name}`
121
+ `mv #{@dynamic_sandbox_root}/build/#{@spec.name}.framework.dSYM #{@platform.name}`
122
+ end
123
+
124
+ def build_dynamic_framework_for_mac(defines, _output)
125
+ # Specify frameworks to link and search paths
126
+ linker_flags = static_linker_flags_in_sandbox
127
+ defines = "#{defines} OTHER_LDFLAGS=\"#{linker_flags.join(' ')}\""
128
+
129
+ # Build Target Dynamic Framework for osx
130
+ defines = "#{defines} LIBRARY_SEARCH_PATHS=\"#{Dir.pwd}/#{@static_sandbox_root}/build\""
131
+ xcodebuild(defines, nil, 'build', @spec.name.to_s, @dynamic_sandbox_root.to_s)
132
+
133
+ FileUtils.mkdir(@platform.name.to_s)
134
+ `mv #{@dynamic_sandbox_root}/build/#{@spec.name}.framework #{@platform.name}`
135
+ `mv #{@dynamic_sandbox_root}/build/#{@spec.name}.framework.dSYM #{@platform.name}`
136
+ end
137
+
138
+ def build_sim_libraries(defines)
139
+ if @platform.name == :ios
140
+ xcodebuild(defines, '-sdk iphonesimulator', 'build-sim')
141
+ end
142
+ end
143
+
144
+ def build_static_library_for_ios(output)
145
+ static_libs = static_libs_in_sandbox('build') + static_libs_in_sandbox('build-sim') + vendored_libraries
146
+ libs = ios_architectures.map do |arch|
147
+ library = "#{@static_sandbox_root}/build/package-#{arch}.a"
148
+ `libtool -arch_only #{arch} -static -o #{library} #{static_libs.join(' ')}`
149
+ library
150
+ end
151
+
152
+ `lipo -create -output #{output} #{libs.join(' ')}`
153
+ end
154
+
155
+ def build_static_library_for_mac(output)
156
+ static_libs = static_libs_in_sandbox + vendored_libraries
157
+ `libtool -static -o #{output} #{static_libs.join(' ')}`
158
+ end
159
+
160
+ def build_with_mangling(options)
161
+ UI.puts 'Mangling symbols'
162
+ defines = Symbols.mangle_for_pod_dependencies(@spec.name, @static_sandbox_root)
163
+ defines << ' ' << @spec.consumer(@platform).compiler_flags.join(' ')
164
+
165
+ UI.puts 'Building mangled framework'
166
+ xcodebuild(defines, options)
167
+ defines
168
+ end
169
+
170
+ def clean_directory_for_dynamic_build
171
+ # Remove static headers to avoid duplicate declaration conflicts
172
+ FileUtils.rm_rf("#{@static_sandbox_root}/Headers/Public/#{@spec.name}")
173
+ FileUtils.rm_rf("#{@static_sandbox_root}/Headers/Private/#{@spec.name}")
174
+
175
+ # Equivalent to removing derrived data
176
+ FileUtils.rm_rf('Pods/build')
177
+ end
178
+
179
+ def compile
180
+ defines = "GCC_PREPROCESSOR_DEFINITIONS='$(inherited) PodsDummy_Pods_#{@spec.name}=PodsDummy_PodPackage_#{@spec.name}'"
181
+ defines << ' ' << @spec.consumer(@platform).compiler_flags.join(' ')
182
+
183
+ if @platform.name == :ios
184
+ options = ios_build_options
185
+ end
186
+
187
+ xcodebuild(defines, options)
188
+
189
+ if @mangle
190
+ return build_with_mangling(options)
191
+ end
192
+
193
+ defines
194
+ end
195
+
196
+ def copy_headers
197
+ headers_source_root = "#{@public_headers_root}/#{@spec.name}"
198
+
199
+ Dir.glob("#{headers_source_root}/**/*.h").
200
+ each { |h| `ditto #{h} #{@fwk.headers_path}/#{h.sub(headers_source_root, '')}` }
201
+
202
+ # If custom 'module_map' is specified add it to the framework distribution
203
+ # otherwise check if a header exists that is equal to 'spec.name', if so
204
+ # create a default 'module_map' one using it.
205
+ if !@spec.module_map.nil?
206
+ module_map_file = @file_accessors.flat_map(&:module_map).first
207
+ module_map = File.read(module_map_file) if Pathname(module_map_file).exist?
208
+ elsif File.exist?("#{@public_headers_root}/#{@spec.name}/#{@spec.name}.h")
209
+ module_map = <<MAP
210
+ framework module #{@spec.name} {
211
+ umbrella header "#{@spec.name}.h"
212
+
213
+ export *
214
+ module * { export * }
215
+ }
216
+ MAP
217
+ end
218
+
219
+ unless module_map.nil?
220
+ @fwk.module_map_path.mkpath unless @fwk.module_map_path.exist?
221
+ File.write("#{@fwk.module_map_path}/module.modulemap", module_map)
222
+ end
223
+ end
224
+
225
+ def copy_license
226
+ license_file = @spec.license[:file] || 'LICENSE'
227
+ license_file = Pathname.new("#{@static_sandbox_root}/#{@spec.name}/#{license_file}")
228
+ FileUtils.cp(license_file, '.') if license_file.exist?
229
+ end
230
+
231
+ def copy_resources
232
+ bundles = Dir.glob("#{@static_sandbox_root}/build/*.bundle")
233
+ if @dynamic
234
+ resources_path = "ios/#{@spec.name}.framework"
235
+ `cp -rp #{@static_sandbox_root}/build/*.bundle #{resources_path} 2>&1`
236
+ else
237
+ `cp -rp #{@static_sandbox_root}/build/*.bundle #{@fwk.resources_path} 2>&1`
238
+ resources = expand_paths(@spec.consumer(@platform).resources)
239
+ if resources.count == 0 && bundles.count == 0
240
+ @fwk.delete_resources
241
+ return
242
+ end
243
+ if resources.count > 0
244
+ `cp -rp #{resources.join(' ')} #{@fwk.resources_path}`
245
+ end
246
+ end
247
+ end
248
+
249
+ def create_framework
250
+ @fwk = Framework::Tree.new(@spec.name, @platform.name.to_s, @embedded)
251
+ @fwk.make
252
+ end
253
+
254
+ def dependency_count
255
+ count = @spec.dependencies.count
256
+
257
+ @spec.subspecs.each do |subspec|
258
+ count += subspec.dependencies.count
259
+ end
260
+
261
+ count
262
+ end
263
+
264
+ def expand_paths(path_specs)
265
+ path_specs.map do |path_spec|
266
+ Dir.glob(File.join(@source_dir, path_spec))
267
+ end
268
+ end
269
+
270
+ def static_libs_in_sandbox(build_dir = 'build')
271
+ if @exclude_deps
272
+ UI.puts 'Excluding dependencies'
273
+ Dir.glob("#{@static_sandbox_root}/#{build_dir}/lib#{@spec.name}.a")
274
+ else
275
+ Dir.glob("#{@static_sandbox_root}/#{build_dir}/lib*.a")
276
+ end
277
+ end
278
+
279
+ def vendored_libraries
280
+ if @vendored_libraries
281
+ @vendored_libraries
282
+ end
283
+ file_accessors = if @exclude_deps
284
+ @file_accessors
285
+ else
286
+ @static_installer.pod_targets.flat_map(&:file_accessors)
287
+ end
288
+ libs = file_accessors.flat_map(&:vendored_static_frameworks).map { |f| f + f.basename('.*') } || []
289
+ libs += file_accessors.flat_map(&:vendored_static_libraries)
290
+ @vendored_libraries = libs.compact.map(&:to_s)
291
+ @vendored_libraries
292
+ end
293
+
294
+ def static_linker_flags_in_sandbox
295
+ linker_flags = static_libs_in_sandbox.map do |lib|
296
+ lib.slice!('lib')
297
+ lib_flag = lib.chomp('.a').split('/').last
298
+ "-l#{lib_flag}"
299
+ end
300
+ linker_flags.reject { |e| e == "-l#{@spec.name}" || e == '-lPods-packager' }
301
+ end
302
+
303
+ def ios_build_options
304
+ "ARCHS=\'#{ios_architectures.join(' ')}\' OTHER_CFLAGS=\'-fembed-bitcode -Qunused-arguments\'"
305
+ end
306
+
307
+ def ios_architectures
308
+ archs = %w(x86_64 arm64 armv7 armv7s)
309
+ vendored_libraries.each do |library|
310
+ archs = `lipo -info #{library}`.split & archs
311
+ end
312
+ archs
313
+ end
314
+
315
+ def xcodebuild(defines = '', args = '', build_dir = 'build', target = 'Pods-packager', project_root = @static_sandbox_root, config = @config)
316
+ if defined?(Pod::DONT_CODESIGN)
317
+ args = "#{args} CODE_SIGN_IDENTITY=\"\" CODE_SIGNING_REQUIRED=NO"
318
+ end
319
+
320
+ command = "xcodebuild #{defines} #{args} CONFIGURATION_BUILD_DIR=#{build_dir} clean build -configuration #{config} -target #{target} -project #{project_root}/Pods.xcodeproj 2>&1"
321
+ output = `#{command}`.lines.to_a
322
+
323
+ if $?.exitstatus != 0
324
+ puts UI::BuildFailedReport.report(command, output)
325
+
326
+ # Note: We use `Process.exit` here because it fires a `SystemExit`
327
+ # exception, which gives the caller a chance to clean up before the
328
+ # process terminates.
329
+ #
330
+ # See http://ruby-doc.org/core-1.9.3/Process.html#method-c-exit
331
+ Process.exit
332
+ end
333
+ end
334
+ end
335
+ end
@@ -0,0 +1,75 @@
1
+ require 'fileutils'
2
+ module Framework
3
+ class Tree
4
+ attr_reader :headers_path
5
+ attr_reader :module_map_path
6
+ attr_reader :resources_path
7
+ attr_reader :root_path
8
+ attr_reader :versions_path
9
+ attr_accessor :fwk_path
10
+ def delete_resources
11
+ Pathname.new(@resources_path).rmtree
12
+ (Pathname.new(@fwk_path) + Pathname.new('Resources')).delete
13
+ end
14
+
15
+ def initialize(name, platform, embedded)
16
+ @name = name
17
+ @platform = platform
18
+ @embedded = embedded
19
+ end
20
+
21
+ def make
22
+ make_root
23
+ make_framework
24
+ make_headers
25
+ make_resources
26
+ make_current_version
27
+ end
28
+
29
+ def process_static_framework
30
+ `rm -rf #{@fwk_path}/Headers`
31
+ `rm -rf #{@fwk_path}/Resources`
32
+ `rm -rf #{@fwk_path}/#{@name}`
33
+ `cp -r #{@versions_path}/* #{fwk_path}`
34
+ `rm -rf #{@fwk_path}/Versions`
35
+ end
36
+
37
+ private
38
+
39
+ def make_current_version
40
+ current_version_path = @versions_path + Pathname.new('../Current')
41
+ `ln -sf A #{current_version_path}`
42
+ `ln -sf Versions/Current/Headers #{@fwk_path}/`
43
+ `ln -sf Versions/Current/Resources #{@fwk_path}/`
44
+ `ln -sf Versions/Current/#{@name} #{@fwk_path}/`
45
+ end
46
+
47
+ def make_framework
48
+ @fwk_path = @root_path + Pathname.new(@name + '.framework')
49
+ @fwk_path.mkdir unless @fwk_path.exist?
50
+
51
+ @module_map_path = @fwk_path + Pathname.new('Modules')
52
+ @versions_path = @fwk_path + Pathname.new('Versions/A')
53
+ end
54
+
55
+ def make_headers
56
+ @headers_path = @versions_path + Pathname.new('Headers')
57
+ @headers_path.mkpath unless @headers_path.exist?
58
+ end
59
+
60
+ def make_resources
61
+ @resources_path = @versions_path + Pathname.new('Resources')
62
+ @resources_path.mkpath unless @resources_path.exist?
63
+ end
64
+
65
+ def make_root
66
+ @root_path = Pathname.new(@platform)
67
+
68
+ if @embedded
69
+ @root_path += Pathname.new(@name + '.embeddedframework')
70
+ end
71
+
72
+ @root_path.mkpath unless @root_path.exist?
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,32 @@
1
+ module Symbols
2
+ #
3
+ # performs symbol aliasing
4
+ #
5
+ # for each dependency:
6
+ # - determine symbols for classes and global constants
7
+ # - alias each symbol to Pod#{pod_name}_#{symbol}
8
+ # - put defines into `GCC_PREPROCESSOR_DEFINITIONS` for passing to Xcode
9
+ #
10
+ def mangle_for_pod_dependencies(pod_name, sandbox_root)
11
+ pod_libs = Dir.glob("#{sandbox_root}/build/lib*.a").select do |file|
12
+ file !~ /lib#{pod_name}.a$/
13
+ end
14
+
15
+ dummy_alias = alias_symbol "PodsDummy_#{pod_name}", pod_name
16
+ all_syms = [dummy_alias]
17
+
18
+ pod_libs.each do |pod_lib|
19
+ syms = Symbols.symbols_from_library(pod_lib)
20
+ all_syms += syms.map! { |sym| alias_symbol sym, pod_name }
21
+ end
22
+
23
+ "GCC_PREPROCESSOR_DEFINITIONS='$(inherited) #{all_syms.uniq.join(' ')}'"
24
+ end
25
+
26
+ def alias_symbol(sym, pod_name)
27
+ pod_name = pod_name.tr('-', '_')
28
+ sym + "=Pod#{pod_name}_" + sym
29
+ end
30
+
31
+ module_function :mangle_for_pod_dependencies, :alias_symbol
32
+ end