cocoapods 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +329 -0
  3. data/lib/cocoapods/command/init.rb +6 -6
  4. data/lib/cocoapods/command/ipc/list.rb +40 -0
  5. data/lib/cocoapods/command/ipc/podfile.rb +31 -0
  6. data/lib/cocoapods/command/ipc/repl.rb +51 -0
  7. data/lib/cocoapods/command/ipc/spec.rb +29 -0
  8. data/lib/cocoapods/command/ipc/update_search_index.rb +24 -0
  9. data/lib/cocoapods/command/ipc.rb +18 -0
  10. data/lib/cocoapods/command/lib/create.rb +105 -0
  11. data/lib/cocoapods/command/lib/lint.rb +111 -0
  12. data/lib/cocoapods/command/lib.rb +3 -207
  13. data/lib/cocoapods/command/repo/push.rb +44 -20
  14. data/lib/cocoapods/command/setup.rb +2 -1
  15. data/lib/cocoapods/command/spec/lint.rb +4 -0
  16. data/lib/cocoapods/command.rb +2 -1
  17. data/lib/cocoapods/config.rb +4 -1
  18. data/lib/cocoapods/downloader/cache.rb +1 -0
  19. data/lib/cocoapods/downloader.rb +20 -0
  20. data/lib/cocoapods/executable.rb +1 -1
  21. data/lib/cocoapods/gem_version.rb +1 -1
  22. data/lib/cocoapods/generator/acknowledgements/plist.rb +4 -1
  23. data/lib/cocoapods/generator/copy_resources_script.rb +4 -10
  24. data/lib/cocoapods/generator/header.rb +2 -1
  25. data/lib/cocoapods/generator/prefix_header.rb +0 -12
  26. data/lib/cocoapods/generator/xcconfig/aggregate_xcconfig.rb +38 -5
  27. data/lib/cocoapods/generator/xcconfig/xcconfig_helper.rb +5 -4
  28. data/lib/cocoapods/installer/analyzer/pod_variant_set.rb +5 -1
  29. data/lib/cocoapods/installer/analyzer/target_inspector.rb +24 -1
  30. data/lib/cocoapods/installer/analyzer.rb +161 -1
  31. data/lib/cocoapods/installer/user_project_integrator/target_integrator.rb +29 -9
  32. data/lib/cocoapods/installer/xcode/pods_project_generator/aggregate_target_installer.rb +204 -0
  33. data/lib/cocoapods/installer/xcode/pods_project_generator/file_references_installer.rb +314 -0
  34. data/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_installer.rb +401 -0
  35. data/lib/cocoapods/installer/xcode/pods_project_generator/target_installer.rb +214 -0
  36. data/lib/cocoapods/installer/xcode/pods_project_generator.rb +265 -0
  37. data/lib/cocoapods/installer/xcode.rb +7 -0
  38. data/lib/cocoapods/installer.rb +50 -214
  39. data/lib/cocoapods/resolver.rb +15 -9
  40. data/lib/cocoapods/sandbox/headers_store.rb +4 -10
  41. data/lib/cocoapods/sandbox/path_list.rb +20 -9
  42. data/lib/cocoapods/sources_manager.rb +7 -10
  43. data/lib/cocoapods/target/aggregate_target.rb +20 -0
  44. data/lib/cocoapods/target/pod_target.rb +37 -7
  45. data/lib/cocoapods/user_interface/error_report.rb +7 -0
  46. data/lib/cocoapods/user_interface/inspector_reporter.rb +109 -0
  47. data/lib/cocoapods/user_interface.rb +7 -5
  48. data/lib/cocoapods/validator.rb +59 -11
  49. metadata +112 -83
  50. data/lib/cocoapods/command/inter_process_communication.rb +0 -177
  51. data/lib/cocoapods/installer/file_references_installer.rb +0 -310
  52. data/lib/cocoapods/installer/migrator.rb +0 -86
  53. data/lib/cocoapods/installer/target_installer/aggregate_target_installer.rb +0 -191
  54. data/lib/cocoapods/installer/target_installer/pod_target_installer.rb +0 -368
  55. data/lib/cocoapods/installer/target_installer.rb +0 -210
@@ -0,0 +1,401 @@
1
+ module Pod
2
+ class Installer
3
+ class Xcode
4
+ class PodsProjectGenerator
5
+ # Creates the target for the Pods libraries in the Pods project and the
6
+ # relative support files.
7
+ #
8
+ class PodTargetInstaller < TargetInstaller
9
+ # Creates the target in the Pods project and the relative support files.
10
+ #
11
+ # @return [void]
12
+ #
13
+ def install!
14
+ unless target.should_build?
15
+ add_resources_bundle_targets
16
+ return
17
+ end
18
+
19
+ UI.message "- Installing target `#{target.name}` #{target.platform}" do
20
+ add_target
21
+ create_support_files_dir
22
+ add_resources_bundle_targets
23
+ add_files_to_build_phases
24
+ create_xcconfig_file
25
+ if target.requires_frameworks?
26
+ create_info_plist_file
27
+ create_module_map
28
+ create_umbrella_header do |generator|
29
+ generator.imports += if header_mappings_dir
30
+ target.file_accessors.flat_map(&:public_headers).map do |pathname|
31
+ pathname.relative_path_from(header_mappings_dir)
32
+ end
33
+ else
34
+ target.file_accessors.flat_map(&:public_headers).map(&:basename)
35
+ end
36
+ end
37
+ create_build_phase_to_symlink_header_folders
38
+ end
39
+ create_prefix_header
40
+ create_dummy_source
41
+ end
42
+ end
43
+
44
+ private
45
+
46
+ # Remove the default headers folder path settings for static library pod
47
+ # targets.
48
+ #
49
+ # @return [Hash{String => String}]
50
+ #
51
+ def custom_build_settings
52
+ settings = super
53
+ unless target.requires_frameworks?
54
+ settings['PRIVATE_HEADERS_FOLDER_PATH'] = ''
55
+ settings['PUBLIC_HEADERS_FOLDER_PATH'] = ''
56
+ end
57
+
58
+ settings['CODE_SIGN_IDENTITY[sdk=appletvos*]'] = ''
59
+ settings['CODE_SIGN_IDENTITY[sdk=iphoneos*]'] = ''
60
+ settings['CODE_SIGN_IDENTITY[sdk=watchos*]'] = ''
61
+
62
+ if target.swift_version
63
+ settings['SWIFT_VERSION'] = target.swift_version
64
+ end
65
+ settings
66
+ end
67
+
68
+ #-----------------------------------------------------------------------#
69
+
70
+ SOURCE_FILE_EXTENSIONS = Sandbox::FileAccessor::SOURCE_FILE_EXTENSIONS
71
+
72
+ # Adds the build files of the pods to the target and adds a reference to
73
+ # the frameworks of the Pods.
74
+ #
75
+ # @note The Frameworks are used only for presentation purposes as the
76
+ # xcconfig is the authoritative source about their information.
77
+ #
78
+ # @note Core Data model directories (.xcdatamodeld) defined in the `resources`
79
+ # property are currently added to the `Copy Resources` build phase like
80
+ # all other resources. The Xcode UI adds these to the `Compile Sources`
81
+ # build phase, but they will compile correctly either way.
82
+ #
83
+ # @return [void]
84
+ #
85
+ def add_files_to_build_phases
86
+ target.file_accessors.each do |file_accessor|
87
+ consumer = file_accessor.spec_consumer
88
+
89
+ headers = file_accessor.headers
90
+ public_headers = file_accessor.public_headers
91
+ private_headers = file_accessor.private_headers
92
+ other_source_files = file_accessor.source_files.reject { |sf| SOURCE_FILE_EXTENSIONS.include?(sf.extname) }
93
+
94
+ {
95
+ true => file_accessor.arc_source_files,
96
+ false => file_accessor.non_arc_source_files,
97
+ }.each do |arc, files|
98
+ files = files - headers - other_source_files
99
+ flags = compiler_flags_for_consumer(consumer, arc)
100
+ regular_file_refs = files.map { |sf| project.reference_for_path(sf) }
101
+ native_target.add_file_references(regular_file_refs, flags)
102
+ end
103
+
104
+ header_file_refs = headers.map { |sf| project.reference_for_path(sf) }
105
+ native_target.add_file_references(header_file_refs) do |build_file|
106
+ add_header(build_file, public_headers, private_headers)
107
+ end
108
+
109
+ other_file_refs = other_source_files.map { |sf| project.reference_for_path(sf) }
110
+ native_target.add_file_references(other_file_refs, nil)
111
+
112
+ next unless target.requires_frameworks?
113
+
114
+ resource_refs = file_accessor.resources.flatten.map do |res|
115
+ project.reference_for_path(res)
116
+ end
117
+
118
+ # Some nested files are not directly present in the Xcode project, such as the contents
119
+ # of an .xcdatamodeld directory. These files will return nil file references.
120
+ resource_refs.compact!
121
+
122
+ native_target.add_resources(resource_refs)
123
+ end
124
+ end
125
+
126
+ # Adds the resources of the Pods to the Pods project.
127
+ #
128
+ # @note The source files are grouped by Pod and in turn by subspec
129
+ # (recursively) in the resources group.
130
+ #
131
+ # @note Core Data model directories (.xcdatamodeld) are currently added to the
132
+ # `Copy Resources` build phase like all other resources. The Xcode UI adds
133
+ # these to the `Compile Sources` build phase, but they will compile
134
+ # correctly either way.
135
+ #
136
+ # @return [void]
137
+ #
138
+ def add_resources_bundle_targets
139
+ target.file_accessors.each do |file_accessor|
140
+ file_accessor.resource_bundles.each do |bundle_name, paths|
141
+ file_references = paths.map do |path|
142
+ ref = project.reference_for_path(path)
143
+
144
+ # Some nested files are not directly present in the Xcode project, such as the contents
145
+ # of an .xcdatamodeld directory. These files are implicitly included by including their
146
+ # parent directory.
147
+ next if ref.nil?
148
+
149
+ # For variant groups, the variant group itself is added, not its members.
150
+ next ref.parent if ref.parent.is_a?(Xcodeproj::Project::Object::PBXVariantGroup)
151
+
152
+ ref
153
+ end
154
+ file_references = file_references.uniq.compact
155
+
156
+ label = target.resources_bundle_target_label(bundle_name)
157
+ bundle_target = project.new_resources_bundle(label, file_accessor.spec_consumer.platform_name)
158
+ bundle_target.product_reference.tap do |bundle_product|
159
+ bundle_file_name = "#{bundle_name}.bundle"
160
+ bundle_product.name = bundle_file_name
161
+ bundle_product.path = bundle_file_name
162
+ end
163
+ bundle_target.add_resources(file_references)
164
+
165
+ target.user_build_configurations.each do |bc_name, type|
166
+ bundle_target.add_build_configuration(bc_name, type)
167
+ end
168
+ bundle_target.deployment_target = deployment_target
169
+
170
+ target.resource_bundle_targets << bundle_target
171
+
172
+ if target.should_build?
173
+ native_target.add_dependency(bundle_target)
174
+ if target.requires_frameworks?
175
+ native_target.add_resources([bundle_target.product_reference])
176
+ end
177
+ end
178
+
179
+ # Create Info.plist file for bundle
180
+ path = target.info_plist_path
181
+ path.dirname.mkdir unless path.dirname.exist?
182
+ info_plist_path = path.dirname + "ResourceBundle-#{bundle_name}-#{path.basename}"
183
+ generator = Generator::InfoPlistFile.new(target, :bundle_package_type => :bndl)
184
+ generator.save_as(info_plist_path)
185
+ add_file_to_support_group(info_plist_path)
186
+
187
+ bundle_target.build_configurations.each do |c|
188
+ c.build_settings['PRODUCT_NAME'] = bundle_name
189
+ relative_info_plist_path = info_plist_path.relative_path_from(sandbox.root)
190
+ c.build_settings['INFOPLIST_FILE'] = relative_info_plist_path.to_s
191
+ c.build_settings['CONFIGURATION_BUILD_DIR'] = target.configuration_build_dir('$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)')
192
+
193
+ # Set the correct device family for this bundle, based on the platform
194
+ device_family_by_platform = {
195
+ :ios => '1,2',
196
+ :tvos => '3',
197
+ :watchos => '1,2' # The device family for watchOS is 4, but Xcode creates watchkit-compatible bundles as 1,2
198
+ }
199
+
200
+ if family = device_family_by_platform[target.platform.name]
201
+ c.build_settings['TARGETED_DEVICE_FAMILY'] = family
202
+ end
203
+ end
204
+ end
205
+ end
206
+ end
207
+
208
+ # Generates the contents of the xcconfig file and saves it to disk.
209
+ #
210
+ # @return [void]
211
+ #
212
+ def create_xcconfig_file
213
+ path = target.xcconfig_path
214
+ xcconfig_gen = Generator::XCConfig::PodXCConfig.new(target)
215
+ xcconfig_gen.save_as(path)
216
+ xcconfig_file_ref = add_file_to_support_group(path)
217
+
218
+ native_target.build_configurations.each do |c|
219
+ c.base_configuration_reference = xcconfig_file_ref
220
+ end
221
+
222
+ # also apply the private config to resource targets
223
+ target.resource_bundle_targets.each do |rsrc_target|
224
+ rsrc_target.build_configurations.each do |rsrc_bc|
225
+ rsrc_bc.base_configuration_reference = xcconfig_file_ref
226
+ end
227
+ end
228
+ end
229
+
230
+ # Creates a build phase which links the versioned header folders
231
+ # of the OS X into the framework bundle's root root directory.
232
+ # This is only necessary because the way how headers are copied
233
+ # via custom copy file build phases in combination with
234
+ # header_mappings_dir interferes with xcodebuild's expectations
235
+ # about the existence of private or public headers.
236
+ #
237
+ # @return [void]
238
+ #
239
+ def create_build_phase_to_symlink_header_folders
240
+ return unless target.platform.name == :osx && header_mappings_dir
241
+
242
+ build_phase = native_target.new_shell_script_build_phase('Create Symlinks to Header Folders')
243
+ build_phase.shell_script = <<-eos.strip_heredoc
244
+ base="$CONFIGURATION_BUILD_DIR/$WRAPPER_NAME"
245
+ ln -fs $base/${PUBLIC_HEADERS_FOLDER_PATH\#$WRAPPER_NAME/} $base/${PUBLIC_HEADERS_FOLDER_PATH\#\$CONTENTS_FOLDER_PATH/}
246
+ ln -fs $base/${PRIVATE_HEADERS_FOLDER_PATH\#\$WRAPPER_NAME/} $base/${PRIVATE_HEADERS_FOLDER_PATH\#\$CONTENTS_FOLDER_PATH/}
247
+ eos
248
+ end
249
+
250
+ # Creates a prefix header file which imports `UIKit` or `Cocoa` according
251
+ # to the platform of the target. This file also include any prefix header
252
+ # content reported by the specification of the pods.
253
+ #
254
+ # @return [void]
255
+ #
256
+ def create_prefix_header
257
+ path = target.prefix_header_path
258
+ generator = Generator::PrefixHeader.new(target.file_accessors, target.platform)
259
+ generator.save_as(path)
260
+ add_file_to_support_group(path)
261
+
262
+ native_target.build_configurations.each do |c|
263
+ relative_path = path.relative_path_from(project.path.dirname)
264
+ c.build_settings['GCC_PREFIX_HEADER'] = relative_path.to_s
265
+ end
266
+ end
267
+
268
+ ENABLE_OBJECT_USE_OBJC_FROM = {
269
+ :ios => Version.new('6'),
270
+ :osx => Version.new('10.8'),
271
+ :watchos => Version.new('2.0'),
272
+ :tvos => Version.new('9.0'),
273
+ }
274
+
275
+ # Returns the compiler flags for the source files of the given specification.
276
+ #
277
+ # The following behavior is regarding the `OS_OBJECT_USE_OBJC` flag. When
278
+ # set to `0`, it will allow code to use `dispatch_release()` on >= iOS 6.0
279
+ # and OS X 10.8.
280
+ #
281
+ # * New libraries that do *not* require ARC don’t need to care about this
282
+ # issue at all.
283
+ #
284
+ # * New libraries that *do* require ARC _and_ have a deployment target of
285
+ # >= iOS 6.0 or OS X 10.8:
286
+ #
287
+ # These no longer use `dispatch_release()` and should *not* have the
288
+ # `OS_OBJECT_USE_OBJC` flag set to `0`.
289
+ #
290
+ # **Note:** this means that these libraries *have* to specify the
291
+ # deployment target in order to function well.
292
+ #
293
+ # * New libraries that *do* require ARC, but have a deployment target of
294
+ # < iOS 6.0 or OS X 10.8:
295
+ #
296
+ # These contain `dispatch_release()` calls and as such need the
297
+ # `OS_OBJECT_USE_OBJC` flag set to `1`.
298
+ #
299
+ # **Note:** libraries that do *not* specify a platform version are
300
+ # assumed to have a deployment target of < iOS 6.0 or OS X 10.8.
301
+ #
302
+ # For more information, see: http://opensource.apple.com/source/libdispatch/libdispatch-228.18/os/object.h
303
+ #
304
+ # @param [Specification::Consumer] consumer
305
+ # The consumer for the specification for which the compiler flags
306
+ # are needed.
307
+ #
308
+ # @return [String] The compiler flags.
309
+ #
310
+ def compiler_flags_for_consumer(consumer, arc)
311
+ flags = consumer.compiler_flags.dup
312
+ if !arc
313
+ flags << '-fno-objc-arc'
314
+ else
315
+ platform_name = consumer.platform_name
316
+ spec_deployment_target = consumer.spec.deployment_target(platform_name)
317
+ if spec_deployment_target.nil? || Version.new(spec_deployment_target) < ENABLE_OBJECT_USE_OBJC_FROM[platform_name]
318
+ flags << '-DOS_OBJECT_USE_OBJC=0'
319
+ end
320
+ end
321
+ if target.inhibit_warnings?
322
+ flags << '-w -Xanalyzer -analyzer-disable-all-checks'
323
+ end
324
+ flags * ' '
325
+ end
326
+
327
+ # Adds a reference to the given file in the support group of this target.
328
+ #
329
+ # @param [Pathname] path
330
+ # The path of the file to which the reference should be added.
331
+ #
332
+ # @return [PBXFileReference] the file reference of the added file.
333
+ #
334
+ def add_file_to_support_group(path)
335
+ pod_name = target.pod_name
336
+ dir = target.support_files_dir
337
+ group = project.pod_support_files_group(pod_name, dir)
338
+ group.new_file(path)
339
+ end
340
+
341
+ def create_module_map
342
+ return super unless custom_module_map
343
+ path = target.module_map_path
344
+ UI.message "- Copying module map file to #{UI.path(path)}" do
345
+ FileUtils.cp(custom_module_map, path)
346
+ add_file_to_support_group(path)
347
+
348
+ native_target.build_configurations.each do |c|
349
+ relative_path = path.relative_path_from(sandbox.root)
350
+ c.build_settings['MODULEMAP_FILE'] = relative_path.to_s
351
+ end
352
+ end
353
+ end
354
+
355
+ def create_umbrella_header
356
+ return super unless custom_module_map
357
+ end
358
+
359
+ def custom_module_map
360
+ @custom_module_map ||= target.file_accessors.first.module_map
361
+ end
362
+
363
+ def header_mappings_dir
364
+ return @header_mappings_dir if defined?(@header_mappings_dir)
365
+ file_accessor = target.file_accessors.first
366
+ @header_mappings_dir = if dir = file_accessor.spec_consumer.header_mappings_dir
367
+ file_accessor.path_list.root + dir
368
+ end
369
+ end
370
+
371
+ def add_header(build_file, public_headers, private_headers)
372
+ file_ref = build_file.file_ref
373
+ acl = if public_headers.include?(file_ref.real_path)
374
+ 'Public'
375
+ elsif private_headers.include?(file_ref.real_path)
376
+ 'Private'
377
+ else
378
+ 'Project'
379
+ end
380
+
381
+ if target.requires_frameworks? && header_mappings_dir && acl != 'Project'
382
+ relative_path = file_ref.real_path.relative_path_from(header_mappings_dir)
383
+ sub_dir = relative_path.dirname
384
+ copy_phase_name = "Copy #{sub_dir} #{acl} Headers"
385
+ copy_phase = native_target.copy_files_build_phases.find { |bp| bp.name == copy_phase_name } ||
386
+ native_target.new_copy_files_build_phase(copy_phase_name)
387
+ copy_phase.symbol_dst_subfolder_spec = :products_directory
388
+ copy_phase.dst_path = "$(#{acl.upcase}_HEADERS_FOLDER_PATH)/#{sub_dir}"
389
+ copy_phase.add_file_reference(file_ref, true)
390
+ else
391
+ build_file.settings ||= {}
392
+ build_file.settings['ATTRIBUTES'] = [acl]
393
+ end
394
+ end
395
+
396
+ #-----------------------------------------------------------------------#
397
+ end
398
+ end
399
+ end
400
+ end
401
+ end
@@ -0,0 +1,214 @@
1
+ module Pod
2
+ class Installer
3
+ class Xcode
4
+ class PodsProjectGenerator
5
+ # Controller class responsible of creating and configuring the static
6
+ # library target in Pods project. It also creates the support file needed
7
+ # by the target.
8
+ #
9
+ class TargetInstaller
10
+ # @return [Sandbox] sandbox the sandbox where the support files should
11
+ # be generated.
12
+ #
13
+ attr_reader :sandbox
14
+
15
+ # @return [Target] The library whose target needs to be generated.
16
+ #
17
+ attr_reader :target
18
+
19
+ # @param [Project] project @see project
20
+ # @param [Target] target @see target
21
+ #
22
+ def initialize(sandbox, target)
23
+ @sandbox = sandbox
24
+ @target = target
25
+ end
26
+
27
+ private
28
+
29
+ #-----------------------------------------------------------------------#
30
+
31
+ # @!group Installation steps
32
+
33
+ # Adds the target for the library to the Pods project with the
34
+ # appropriate build configurations.
35
+ #
36
+ # @note The `PODS_HEADERS_SEARCH_PATHS` overrides the xcconfig.
37
+ #
38
+ # @return [void]
39
+ #
40
+ def add_target
41
+ product_type = target.product_type
42
+ name = target.label
43
+ platform = target.platform.name
44
+ language = target.uses_swift? ? :swift : :objc
45
+ @native_target = project.new_target(product_type, name, platform, deployment_target, nil, language)
46
+
47
+ product_name = target.product_name
48
+ product = @native_target.product_reference
49
+ product.name = product_name
50
+
51
+ target.user_build_configurations.each do |bc_name, type|
52
+ @native_target.add_build_configuration(bc_name, type)
53
+ end
54
+
55
+ @native_target.build_configurations.each do |configuration|
56
+ configuration.build_settings.merge!(custom_build_settings)
57
+ end
58
+
59
+ target.native_target = @native_target
60
+ end
61
+
62
+ # @return [String] The deployment target.
63
+ #
64
+ def deployment_target
65
+ target.platform.deployment_target.to_s
66
+ end
67
+
68
+ # Returns the customized build settings which are overridden in the build
69
+ # settings of the user target.
70
+ #
71
+ # @return [Hash{String => String}]
72
+ #
73
+ def custom_build_settings
74
+ settings = {}
75
+
76
+ unless target.archs.empty?
77
+ settings['ARCHS'] = target.archs
78
+ end
79
+
80
+ if target.requires_frameworks?
81
+ settings['PRODUCT_NAME'] = target.product_module_name
82
+ else
83
+ settings.merge!('OTHER_LDFLAGS' => '', 'OTHER_LIBTOOLFLAGS' => '')
84
+ end
85
+
86
+ settings
87
+ end
88
+
89
+ # Creates the directory where to store the support files of the target.
90
+ #
91
+ def create_support_files_dir
92
+ target.support_files_dir.mkdir
93
+ end
94
+
95
+ # Creates the Info.plist file which sets public framework attributes
96
+ #
97
+ # @return [void]
98
+ #
99
+ def create_info_plist_file
100
+ path = target.info_plist_path
101
+ UI.message "- Generating Info.plist file at #{UI.path(path)}" do
102
+ generator = Generator::InfoPlistFile.new(target)
103
+ generator.save_as(path)
104
+ add_file_to_support_group(path)
105
+
106
+ native_target.build_configurations.each do |c|
107
+ relative_path = path.relative_path_from(sandbox.root)
108
+ c.build_settings['INFOPLIST_FILE'] = relative_path.to_s
109
+ end
110
+ end
111
+ end
112
+
113
+ # Creates the module map file which ensures that the umbrella header is
114
+ # recognized with a customized path
115
+ #
116
+ # @yield_param [Generator::ModuleMap]
117
+ # yielded once to configure the private headers
118
+ #
119
+ # @return [void]
120
+ #
121
+ def create_module_map
122
+ path = target.module_map_path
123
+ UI.message "- Generating module map file at #{UI.path(path)}" do
124
+ generator = Generator::ModuleMap.new(target)
125
+ yield generator if block_given?
126
+ generator.save_as(path)
127
+ add_file_to_support_group(path)
128
+
129
+ native_target.build_configurations.each do |c|
130
+ relative_path = path.relative_path_from(sandbox.root)
131
+ c.build_settings['MODULEMAP_FILE'] = relative_path.to_s
132
+ end
133
+ end
134
+ end
135
+
136
+ # Generates a header which ensures that all header files are exported
137
+ # in the module map
138
+ #
139
+ # @yield_param [Generator::UmbrellaHeader]
140
+ # yielded once to configure the imports
141
+ #
142
+ def create_umbrella_header
143
+ path = target.umbrella_header_path
144
+ UI.message "- Generating umbrella header at #{UI.path(path)}" do
145
+ generator = Generator::UmbrellaHeader.new(target)
146
+ yield generator if block_given?
147
+ generator.save_as(path)
148
+
149
+ # Add the file to the support group and the native target,
150
+ # so it will been added to the header build phase
151
+ file_ref = add_file_to_support_group(path)
152
+ native_target.add_file_references([file_ref])
153
+
154
+ # Make the umbrella header public
155
+ build_file = native_target.headers_build_phase.build_file(file_ref)
156
+ build_file.settings ||= {}
157
+ build_file.settings['ATTRIBUTES'] = ['Public']
158
+ end
159
+ end
160
+
161
+ # Generates a dummy source file for each target so libraries that contain
162
+ # only categories build.
163
+ #
164
+ # @return [void]
165
+ #
166
+ def create_dummy_source
167
+ path = target.dummy_source_path
168
+ generator = Generator::DummySource.new(target.label)
169
+ generator.save_as(path)
170
+ file_reference = add_file_to_support_group(path)
171
+ native_target.source_build_phase.add_file_reference(file_reference)
172
+ end
173
+
174
+ # @return [PBXNativeTarget] the target generated by the installation
175
+ # process.
176
+ #
177
+ # @note Generated by the {#add_target} step.
178
+ #
179
+ attr_reader :native_target
180
+
181
+ private
182
+
183
+ #-----------------------------------------------------------------------#
184
+
185
+ # @!group Private helpers.
186
+
187
+ # @return [Project] the Pods project of the sandbox.
188
+ #
189
+ def project
190
+ sandbox.project
191
+ end
192
+
193
+ # @return [PBXGroup] the group where the file references to the support
194
+ # files should be stored.
195
+ #
196
+ attr_reader :support_files_group
197
+
198
+ # Adds a reference to the given file in the support group of this target.
199
+ #
200
+ # @param [Pathname] path
201
+ # The path of the file to which the reference should be added.
202
+ #
203
+ # @return [PBXFileReference] the file reference of the added file.
204
+ #
205
+ def add_file_to_support_group(path)
206
+ support_files_group.new_file(path)
207
+ end
208
+
209
+ #-----------------------------------------------------------------------#
210
+ end
211
+ end
212
+ end
213
+ end
214
+ end