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