cocoapods 1.5.3 → 1.6.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 +200 -0
- data/lib/cocoapods.rb +0 -1
- data/lib/cocoapods/command/init.rb +1 -1
- data/lib/cocoapods/command/install.rb +7 -0
- data/lib/cocoapods/command/lib/lint.rb +8 -1
- data/lib/cocoapods/command/outdated.rb +2 -7
- data/lib/cocoapods/command/repo/add.rb +1 -1
- data/lib/cocoapods/command/repo/list.rb +1 -1
- data/lib/cocoapods/command/repo/push.rb +17 -12
- data/lib/cocoapods/command/repo/remove.rb +1 -1
- data/lib/cocoapods/command/repo/update.rb +1 -1
- data/lib/cocoapods/command/setup.rb +1 -1
- data/lib/cocoapods/command/spec/create.rb +39 -39
- data/lib/cocoapods/command/spec/lint.rb +8 -1
- data/lib/cocoapods/config.rb +13 -2
- data/lib/cocoapods/downloader/cache.rb +1 -1
- data/lib/cocoapods/executable.rb +2 -2
- data/lib/cocoapods/external_sources.rb +7 -4
- data/lib/cocoapods/external_sources/abstract_external_source.rb +23 -13
- data/lib/cocoapods/gem_version.rb +1 -1
- data/lib/cocoapods/generator/acknowledgements/markdown.rb +6 -0
- data/lib/cocoapods/generator/acknowledgements/plist.rb +11 -0
- data/lib/cocoapods/generator/app_target_helper.rb +102 -16
- data/lib/cocoapods/generator/copy_resources_script.rb +6 -0
- data/lib/cocoapods/generator/dummy_source.rb +14 -5
- data/lib/cocoapods/generator/embed_frameworks_script.rb +13 -2
- data/lib/cocoapods/generator/header.rb +1 -1
- data/lib/cocoapods/generator/info_plist_file.rb +12 -4
- data/lib/cocoapods/generator/prefix_header.rb +2 -2
- data/lib/cocoapods/hooks_manager.rb +28 -17
- data/lib/cocoapods/installer.rb +103 -42
- data/lib/cocoapods/installer/analyzer.rb +362 -277
- data/lib/cocoapods/installer/analyzer/analysis_result.rb +52 -22
- data/lib/cocoapods/installer/analyzer/locking_dependency_analyzer.rb +9 -6
- data/lib/cocoapods/installer/analyzer/pod_variant.rb +4 -5
- data/lib/cocoapods/installer/analyzer/sandbox_analyzer.rb +3 -14
- data/lib/cocoapods/installer/analyzer/specs_state.rb +28 -4
- data/lib/cocoapods/installer/analyzer/target_inspection_result.rb +24 -16
- data/lib/cocoapods/installer/analyzer/target_inspector.rb +17 -11
- data/lib/cocoapods/installer/pod_source_installer.rb +31 -43
- data/lib/cocoapods/installer/post_install_hooks_context.rb +71 -46
- data/lib/cocoapods/installer/pre_install_hooks_context.rb +22 -13
- data/lib/cocoapods/installer/source_provider_hooks_context.rb +3 -1
- data/lib/cocoapods/installer/user_project_integrator.rb +0 -2
- data/lib/cocoapods/installer/user_project_integrator/target_integrator.rb +38 -28
- data/lib/cocoapods/installer/user_project_integrator/target_integrator/xcconfig_integrator.rb +44 -11
- data/lib/cocoapods/installer/xcode/pods_project_generator.rb +129 -119
- data/lib/cocoapods/installer/xcode/pods_project_generator/aggregate_target_installer.rb +25 -16
- data/lib/cocoapods/installer/xcode/pods_project_generator/app_host_installer.rb +95 -0
- data/lib/cocoapods/installer/xcode/pods_project_generator/file_references_installer.rb +12 -45
- data/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_installer.rb +277 -169
- data/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_integrator.rb +31 -24
- data/lib/cocoapods/installer/xcode/pods_project_generator/target_installation_result.rb +93 -0
- data/lib/cocoapods/installer/xcode/pods_project_generator/target_installer.rb +60 -69
- data/lib/cocoapods/installer/xcode/pods_project_generator/target_installer_helper.rb +72 -0
- data/lib/cocoapods/installer/xcode/target_validator.rb +15 -9
- data/lib/cocoapods/project.rb +14 -14
- data/lib/cocoapods/resolver.rb +38 -50
- data/lib/cocoapods/sandbox.rb +22 -38
- data/lib/cocoapods/sandbox/file_accessor.rb +11 -6
- data/lib/cocoapods/sandbox/headers_store.rb +9 -8
- data/lib/cocoapods/sandbox/path_list.rb +5 -8
- data/lib/cocoapods/sources_manager.rb +1 -1
- data/lib/cocoapods/target.rb +92 -37
- data/lib/cocoapods/target/aggregate_target.rb +140 -84
- data/lib/cocoapods/target/build_settings.rb +1076 -0
- data/lib/cocoapods/target/pod_target.rb +198 -294
- data/lib/cocoapods/user_interface.rb +5 -0
- data/lib/cocoapods/validator.rb +133 -41
- metadata +18 -18
- data/lib/cocoapods/generator/xcconfig.rb +0 -13
- data/lib/cocoapods/generator/xcconfig/aggregate_xcconfig.rb +0 -260
- data/lib/cocoapods/generator/xcconfig/pod_xcconfig.rb +0 -87
- data/lib/cocoapods/generator/xcconfig/xcconfig_helper.rb +0 -558
@@ -1,13 +0,0 @@
|
|
1
|
-
module Pod
|
2
|
-
module Generator
|
3
|
-
# Generates Xcode configuration files. A configuration file is generated
|
4
|
-
# for each Pod and for each Pod target definition. The aggregates the
|
5
|
-
# configurations of the Pods and define target specific settings.
|
6
|
-
#
|
7
|
-
module XCConfig
|
8
|
-
autoload :AggregateXCConfig, 'cocoapods/generator/xcconfig/aggregate_xcconfig'
|
9
|
-
autoload :PodXCConfig, 'cocoapods/generator/xcconfig/pod_xcconfig'
|
10
|
-
autoload :XCConfigHelper, 'cocoapods/generator/xcconfig/xcconfig_helper'
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,260 +0,0 @@
|
|
1
|
-
module Pod
|
2
|
-
module Generator
|
3
|
-
module XCConfig
|
4
|
-
# Generates the xcconfigs for the aggregate targets.
|
5
|
-
#
|
6
|
-
class AggregateXCConfig
|
7
|
-
# @return [AggregateTarget] the target represented by this xcconfig.
|
8
|
-
#
|
9
|
-
attr_reader :target
|
10
|
-
|
11
|
-
# @return [String] the name of the build configuration to generate this
|
12
|
-
# xcconfig for.
|
13
|
-
#
|
14
|
-
attr_reader :configuration_name
|
15
|
-
|
16
|
-
# Initialize a new instance
|
17
|
-
#
|
18
|
-
# @param [Target] target @see target
|
19
|
-
#
|
20
|
-
# @param [String] configuration_name @see configuration_name
|
21
|
-
#
|
22
|
-
def initialize(target, configuration_name)
|
23
|
-
@target = target
|
24
|
-
@configuration_name = configuration_name
|
25
|
-
end
|
26
|
-
|
27
|
-
# @return [Xcodeproj::Config] The generated xcconfig.
|
28
|
-
#
|
29
|
-
attr_reader :xcconfig
|
30
|
-
|
31
|
-
# Generates and saves the xcconfig to the given path.
|
32
|
-
#
|
33
|
-
# @param [Pathname] path
|
34
|
-
# the path where the xcconfig should be stored.
|
35
|
-
#
|
36
|
-
# @return [void]
|
37
|
-
#
|
38
|
-
def save_as(path)
|
39
|
-
generate.save_as(path)
|
40
|
-
end
|
41
|
-
|
42
|
-
# Generates the xcconfig.
|
43
|
-
#
|
44
|
-
# @note The xcconfig file for a Pods integration target includes the
|
45
|
-
# namespaced xcconfig files for each spec target dependency.
|
46
|
-
# Each namespaced configuration value is merged into the Pod
|
47
|
-
# xcconfig file.
|
48
|
-
#
|
49
|
-
# @todo This doesn't include the specs xcconfigs anymore and now the
|
50
|
-
# logic is duplicated.
|
51
|
-
#
|
52
|
-
# @return [Xcodeproj::Config]
|
53
|
-
#
|
54
|
-
def generate
|
55
|
-
includes_static_libs = !target.requires_frameworks?
|
56
|
-
includes_static_libs ||= pod_targets.flat_map(&:file_accessors).any? { |fa| !fa.vendored_static_artifacts.empty? }
|
57
|
-
config = {
|
58
|
-
'FRAMEWORK_SEARCH_PATHS' => '$(inherited) ',
|
59
|
-
'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) COCOAPODS=1',
|
60
|
-
'HEADER_SEARCH_PATHS' => '$(inherited) ',
|
61
|
-
'LIBRARY_SEARCH_PATHS' => '$(inherited) ',
|
62
|
-
'OTHER_CFLAGS' => '$(inherited) ',
|
63
|
-
'OTHER_LDFLAGS' => '$(inherited) ' + XCConfigHelper.default_ld_flags(target, includes_static_libs),
|
64
|
-
'OTHER_SWIFT_FLAGS' => '$(inherited) ',
|
65
|
-
'PODS_PODFILE_DIR_PATH' => target.podfile_dir_relative_path,
|
66
|
-
'PODS_ROOT' => target.relative_pods_root,
|
67
|
-
'SWIFT_INCLUDE_PATHS' => '$(inherited) ',
|
68
|
-
}.merge(embedded_content_settings)
|
69
|
-
|
70
|
-
@xcconfig = Xcodeproj::Config.new(config)
|
71
|
-
|
72
|
-
@xcconfig.merge!(merged_user_target_xcconfigs)
|
73
|
-
|
74
|
-
generate_settings_to_import_pod_targets
|
75
|
-
|
76
|
-
XCConfigHelper.add_target_specific_settings(target, @xcconfig)
|
77
|
-
|
78
|
-
targets = pod_targets + target.search_paths_aggregate_targets.flat_map(&:pod_targets)
|
79
|
-
XCConfigHelper.generate_vendored_build_settings(target, targets, @xcconfig)
|
80
|
-
XCConfigHelper.generate_other_ld_flags(target, pod_targets, @xcconfig)
|
81
|
-
|
82
|
-
# TODO: Need to decide how we are going to ensure settings like these
|
83
|
-
# are always excluded from the user's project.
|
84
|
-
#
|
85
|
-
# See https://github.com/CocoaPods/CocoaPods/issues/1216
|
86
|
-
@xcconfig.attributes.delete('USE_HEADERMAP')
|
87
|
-
|
88
|
-
# If any of the aggregate target dependencies bring in any vendored dynamic artifacts we should ensure to
|
89
|
-
# update the runpath search paths.
|
90
|
-
vendored_dynamic_artifacts = pod_targets.flat_map(&:file_accessors).flat_map(&:vendored_dynamic_artifacts)
|
91
|
-
|
92
|
-
symbol_type = target.user_targets.map(&:symbol_type).uniq.first
|
93
|
-
test_bundle = symbol_type == :octest_bundle || symbol_type == :unit_test_bundle || symbol_type == :ui_test_bundle
|
94
|
-
XCConfigHelper.generate_ld_runpath_search_paths(target, target.requires_host_target?, test_bundle, @xcconfig) if target.requires_frameworks? || vendored_dynamic_artifacts.count > 0
|
95
|
-
|
96
|
-
@xcconfig
|
97
|
-
end
|
98
|
-
|
99
|
-
#---------------------------------------------------------------------#
|
100
|
-
|
101
|
-
protected
|
102
|
-
|
103
|
-
# @return String the SWIFT_VERSION of the target being integrated
|
104
|
-
#
|
105
|
-
def target_swift_version
|
106
|
-
target.target_definition.swift_version unless target.target_definition.swift_version.blank?
|
107
|
-
end
|
108
|
-
|
109
|
-
EMBED_STANDARD_LIBRARIES_MINIMUM_VERSION = Version.new('2.3')
|
110
|
-
|
111
|
-
# @return [Hash<String, String>] the build settings necessary for Swift
|
112
|
-
# targets to be correctly embedded in their host.
|
113
|
-
#
|
114
|
-
def embedded_content_settings
|
115
|
-
# For embedded targets, which live in a host target, CocoaPods
|
116
|
-
# copies all of the embedded target's pod_targets its host
|
117
|
-
# target. Therefore, this check will properly require the Swift
|
118
|
-
# libs in the host target, if the embedded target has any pod targets
|
119
|
-
# that use Swift. Setting this for the embedded target would
|
120
|
-
# cause an App Store rejection because frameworks cannot be embedded
|
121
|
-
# in embedded targets.
|
122
|
-
|
123
|
-
swift_version = Version.new(target_swift_version)
|
124
|
-
should_embed = !target.requires_host_target? && pod_targets.any?(&:uses_swift?)
|
125
|
-
config = {}
|
126
|
-
if should_embed
|
127
|
-
if swift_version >= EMBED_STANDARD_LIBRARIES_MINIMUM_VERSION
|
128
|
-
config['ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES'] = 'YES'
|
129
|
-
else
|
130
|
-
config['EMBEDDED_CONTENT_CONTAINS_SWIFT'] = 'YES'
|
131
|
-
end
|
132
|
-
end
|
133
|
-
config
|
134
|
-
end
|
135
|
-
|
136
|
-
# @return [Hash<String, String>] the build settings necessary to import
|
137
|
-
# the pod targets.
|
138
|
-
#
|
139
|
-
def settings_to_import_pod_targets
|
140
|
-
if target.requires_frameworks?
|
141
|
-
build_pod_targets = pod_targets.select(&:should_build?)
|
142
|
-
framework_header_search_paths = build_pod_targets.map do |target|
|
143
|
-
"#{target.build_product_path}/Headers"
|
144
|
-
end
|
145
|
-
build_settings = {
|
146
|
-
# TODO: remove quote imports in CocoaPods 2.0
|
147
|
-
# Make framework headers discoverable by `import "…"`
|
148
|
-
'OTHER_CFLAGS' => XCConfigHelper.quote(framework_header_search_paths, '-iquote'),
|
149
|
-
}
|
150
|
-
if pod_targets.any? { |t| !t.should_build? }
|
151
|
-
# Make library headers discoverable by `#import "…"`
|
152
|
-
library_header_search_paths = target.sandbox.public_headers.search_paths(target.platform)
|
153
|
-
# TODO: remove quote imports in CocoaPods 2.0
|
154
|
-
build_settings['HEADER_SEARCH_PATHS'] = XCConfigHelper.quote(library_header_search_paths)
|
155
|
-
build_settings['OTHER_CFLAGS'] += ' ' + XCConfigHelper.quote(library_header_search_paths, '-isystem')
|
156
|
-
end
|
157
|
-
build_settings
|
158
|
-
else
|
159
|
-
# Make headers discoverable from $PODS_ROOT/Headers directory
|
160
|
-
header_search_paths = target.sandbox.public_headers.search_paths(target.platform)
|
161
|
-
{
|
162
|
-
# TODO: remove quote imports in CocoaPods 2.0
|
163
|
-
# by `#import "…"`
|
164
|
-
'HEADER_SEARCH_PATHS' => XCConfigHelper.quote(header_search_paths),
|
165
|
-
# by `#import <…>`
|
166
|
-
'OTHER_CFLAGS' => XCConfigHelper.quote(header_search_paths, '-isystem'),
|
167
|
-
}
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
private
|
172
|
-
|
173
|
-
# Add build settings, which ensure that the pod targets can be imported from the integrating target.
|
174
|
-
# For >= 1.5.0 we use modular (stricter) header search paths this means that the integrated target will only be
|
175
|
-
# able to import public headers using `<>` or `@import` notation, but never import any private headers.
|
176
|
-
#
|
177
|
-
# For < 1.5.0 legacy header search paths the same rules apply: It's the wild west.
|
178
|
-
#
|
179
|
-
def generate_settings_to_import_pod_targets
|
180
|
-
@xcconfig.merge! XCConfigHelper.search_paths_for_dependent_targets(target, pod_targets)
|
181
|
-
@xcconfig.merge!(settings_to_import_pod_targets)
|
182
|
-
target.search_paths_aggregate_targets.each do |search_paths_target|
|
183
|
-
generator = AggregateXCConfig.new(search_paths_target, configuration_name)
|
184
|
-
@xcconfig.merge! XCConfigHelper.search_paths_for_dependent_targets(nil, search_paths_target.pod_targets)
|
185
|
-
@xcconfig.merge!(generator.settings_to_import_pod_targets)
|
186
|
-
# Propagate any HEADER_SEARCH_PATHS settings from the search paths.
|
187
|
-
XCConfigHelper.propagate_header_search_paths_from_search_paths(search_paths_target, @xcconfig)
|
188
|
-
end
|
189
|
-
end
|
190
|
-
|
191
|
-
private
|
192
|
-
|
193
|
-
#---------------------------------------------------------------------#
|
194
|
-
|
195
|
-
# !@group Private Helpers
|
196
|
-
|
197
|
-
# Returns the {PodTarget}s which are active for the current
|
198
|
-
# configuration name.
|
199
|
-
#
|
200
|
-
# @return [Array<PodTarget>]
|
201
|
-
#
|
202
|
-
def pod_targets
|
203
|
-
target.pod_targets_for_build_configuration(configuration_name)
|
204
|
-
end
|
205
|
-
|
206
|
-
# Returns the +user_target_xcconfig+ for all pod targets and their spec
|
207
|
-
# consumers grouped by keys
|
208
|
-
#
|
209
|
-
# @return [Hash{String,Hash{Target,String}]
|
210
|
-
#
|
211
|
-
def user_target_xcconfig_values_by_consumer_by_key
|
212
|
-
pod_targets.each_with_object({}) do |target, hash|
|
213
|
-
target.spec_consumers.each do |spec_consumer|
|
214
|
-
spec_consumer.user_target_xcconfig.each do |k, v|
|
215
|
-
(hash[k] ||= {})[spec_consumer] = v
|
216
|
-
end
|
217
|
-
end
|
218
|
-
end
|
219
|
-
end
|
220
|
-
|
221
|
-
# Merges the +user_target_xcconfig+ for all pod targets into the
|
222
|
-
# #xcconfig and warns on conflicting definitions.
|
223
|
-
#
|
224
|
-
# @return [Hash{String, String}]
|
225
|
-
#
|
226
|
-
def merged_user_target_xcconfigs
|
227
|
-
settings = user_target_xcconfig_values_by_consumer_by_key
|
228
|
-
settings.each_with_object({}) do |(key, values_by_consumer), xcconfig|
|
229
|
-
uniq_values = values_by_consumer.values.uniq
|
230
|
-
values_are_bools = uniq_values.all? { |v| v =~ /^(yes|no)$/i }
|
231
|
-
if values_are_bools
|
232
|
-
# Boolean build settings
|
233
|
-
if uniq_values.count > 1
|
234
|
-
UI.warn 'Can\'t merge user_target_xcconfig for pod targets: ' \
|
235
|
-
"#{values_by_consumer.keys.map(&:name)}. Boolean build "\
|
236
|
-
"setting #{key} has different values."
|
237
|
-
else
|
238
|
-
xcconfig[key] = uniq_values.first
|
239
|
-
end
|
240
|
-
elsif key =~ /S$/
|
241
|
-
# Plural build settings
|
242
|
-
xcconfig[key] = uniq_values.join(' ')
|
243
|
-
else
|
244
|
-
# Singular build settings
|
245
|
-
if uniq_values.count > 1
|
246
|
-
UI.warn 'Can\'t merge user_target_xcconfig for pod targets: ' \
|
247
|
-
"#{values_by_consumer.keys.map(&:name)}. Singular build "\
|
248
|
-
"setting #{key} has different values."
|
249
|
-
else
|
250
|
-
xcconfig[key] = uniq_values.first
|
251
|
-
end
|
252
|
-
end
|
253
|
-
end
|
254
|
-
end
|
255
|
-
|
256
|
-
#---------------------------------------------------------------------#
|
257
|
-
end
|
258
|
-
end
|
259
|
-
end
|
260
|
-
end
|
@@ -1,87 +0,0 @@
|
|
1
|
-
module Pod
|
2
|
-
module Generator
|
3
|
-
module XCConfig
|
4
|
-
# Generates the private xcconfigs for the pod targets.
|
5
|
-
#
|
6
|
-
# The xcconfig file for a Pod target merges the pod target
|
7
|
-
# configuration values with the default configuration values
|
8
|
-
# required by CocoaPods.
|
9
|
-
#
|
10
|
-
class PodXCConfig
|
11
|
-
# @return [Target] the target represented by this xcconfig.
|
12
|
-
#
|
13
|
-
attr_reader :target
|
14
|
-
|
15
|
-
# Initialize a new instance
|
16
|
-
#
|
17
|
-
# @param [Target] target @see target
|
18
|
-
#
|
19
|
-
# @param [Boolean] test_xcconfig
|
20
|
-
# whether this is an xcconfig for a test native target.
|
21
|
-
#
|
22
|
-
def initialize(target, test_xcconfig = false)
|
23
|
-
@target = target
|
24
|
-
@test_xcconfig = test_xcconfig
|
25
|
-
end
|
26
|
-
|
27
|
-
# @return [Xcodeproj::Config] The generated xcconfig.
|
28
|
-
#
|
29
|
-
attr_reader :xcconfig
|
30
|
-
|
31
|
-
# Generates and saves the xcconfig to the given path.
|
32
|
-
#
|
33
|
-
# @param [Pathname] path
|
34
|
-
# the path where the prefix header should be stored.
|
35
|
-
#
|
36
|
-
# @return [void]
|
37
|
-
#
|
38
|
-
def save_as(path)
|
39
|
-
generate.save_as(path)
|
40
|
-
end
|
41
|
-
|
42
|
-
# Generates the xcconfig.
|
43
|
-
#
|
44
|
-
# @return [Xcodeproj::Config]
|
45
|
-
#
|
46
|
-
def generate
|
47
|
-
config = {
|
48
|
-
'FRAMEWORK_SEARCH_PATHS' => '$(inherited) ',
|
49
|
-
'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) COCOAPODS=1',
|
50
|
-
'HEADER_SEARCH_PATHS' => '$(inherited) ' + XCConfigHelper.quote(target.header_search_paths(@test_xcconfig)),
|
51
|
-
'LIBRARY_SEARCH_PATHS' => '$(inherited) ',
|
52
|
-
'OTHER_CFLAGS' => '$(inherited) ',
|
53
|
-
'OTHER_LDFLAGS' => XCConfigHelper.default_ld_flags(target, @test_xcconfig),
|
54
|
-
'OTHER_SWIFT_FLAGS' => '$(inherited) ',
|
55
|
-
'PODS_ROOT' => '${SRCROOT}',
|
56
|
-
'PODS_TARGET_SRCROOT' => target.pod_target_srcroot,
|
57
|
-
'PRODUCT_BUNDLE_IDENTIFIER' => 'org.cocoapods.${PRODUCT_NAME:rfc1034identifier}',
|
58
|
-
'SKIP_INSTALL' => 'YES',
|
59
|
-
'SWIFT_ACTIVE_COMPILATION_CONDITIONS' => '$(inherited) ',
|
60
|
-
'SWIFT_INCLUDE_PATHS' => '$(inherited) ',
|
61
|
-
}
|
62
|
-
|
63
|
-
@xcconfig = Xcodeproj::Config.new(config)
|
64
|
-
|
65
|
-
XCConfigHelper.add_settings_for_file_accessors_of_target(nil, target, @xcconfig, true, @test_xcconfig)
|
66
|
-
target.file_accessors.each do |file_accessor|
|
67
|
-
@xcconfig.merge!(file_accessor.spec_consumer.pod_target_xcconfig) if @test_xcconfig == file_accessor.spec.test_specification?
|
68
|
-
end
|
69
|
-
XCConfigHelper.add_target_specific_settings(target, @xcconfig)
|
70
|
-
recursive_dependent_targets = target.recursive_dependent_targets
|
71
|
-
@xcconfig.merge! XCConfigHelper.search_paths_for_dependent_targets(target, recursive_dependent_targets, @test_xcconfig)
|
72
|
-
XCConfigHelper.generate_vendored_build_settings(target, recursive_dependent_targets, @xcconfig, false, @test_xcconfig)
|
73
|
-
if @test_xcconfig
|
74
|
-
test_dependent_targets = [target, *target.recursive_test_dependent_targets].uniq
|
75
|
-
@xcconfig.merge! XCConfigHelper.search_paths_for_dependent_targets(target, test_dependent_targets - recursive_dependent_targets, @test_xcconfig)
|
76
|
-
XCConfigHelper.generate_vendored_build_settings(nil, target.all_dependent_targets, @xcconfig, true, @test_xcconfig)
|
77
|
-
XCConfigHelper.generate_other_ld_flags(nil, target.all_dependent_targets, @xcconfig)
|
78
|
-
XCConfigHelper.generate_ld_runpath_search_paths(target, false, true, @xcconfig)
|
79
|
-
end
|
80
|
-
@xcconfig
|
81
|
-
end
|
82
|
-
|
83
|
-
#-----------------------------------------------------------------------#
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
@@ -1,558 +0,0 @@
|
|
1
|
-
require 'active_support/core_ext/object/try'
|
2
|
-
|
3
|
-
module Pod
|
4
|
-
module Generator
|
5
|
-
module XCConfig
|
6
|
-
# Stores the shared logic of the classes of the XCConfig module.
|
7
|
-
#
|
8
|
-
module XCConfigHelper
|
9
|
-
# @return [String] Used as alias for BUILD_DIR, so that when this
|
10
|
-
# is overridden in the user target, the user can override
|
11
|
-
# this variable to point to the standard directory, which
|
12
|
-
# will be used by CocoaPods.
|
13
|
-
#
|
14
|
-
BUILD_DIR_VARIABLE = '${PODS_BUILD_DIR}'.freeze
|
15
|
-
|
16
|
-
# @return [String] Used as alias for CONFIGURATION_BUILD_DIR, so that
|
17
|
-
# when this is overridden per {PodTarget}, it is still possible
|
18
|
-
# to reference other build products relative to the original
|
19
|
-
# path. Furthermore if it was overridden in the user target,
|
20
|
-
# the user can override this variable to point to the standard
|
21
|
-
# directory, which will be used by CocoaPods.
|
22
|
-
#
|
23
|
-
CONFIGURATION_BUILD_DIR_VARIABLE = '${PODS_CONFIGURATION_BUILD_DIR}'.freeze
|
24
|
-
|
25
|
-
# Converts an array of strings to a single string where the each string
|
26
|
-
# is surrounded by double quotes and separated by a space. Used to
|
27
|
-
# represent strings in a xcconfig file.
|
28
|
-
#
|
29
|
-
# @param [Array<String>] strings
|
30
|
-
# a list of strings.
|
31
|
-
#
|
32
|
-
# @param [String] prefix
|
33
|
-
# optional prefix, such as a flag or option.
|
34
|
-
#
|
35
|
-
# @return [String] the resulting string.
|
36
|
-
#
|
37
|
-
def self.quote(strings, prefix = nil)
|
38
|
-
prefix = "#{prefix} " if prefix
|
39
|
-
strings.sort.map { |s| %W( #{prefix}"#{s}" ) }.join(' ')
|
40
|
-
end
|
41
|
-
|
42
|
-
# Return the default linker flags
|
43
|
-
#
|
44
|
-
# @param [Target] target
|
45
|
-
# the target, which is used to check if the ARC compatibility
|
46
|
-
# flag is required.
|
47
|
-
#
|
48
|
-
# @param [Boolean] include_objc_flag
|
49
|
-
# whether to include `-ObjC` in the other linker flags
|
50
|
-
#
|
51
|
-
# @return [String] the default linker flags. `-ObjC` is optionally included depending
|
52
|
-
# on the target while `-fobjc-arc` is included only if requested in the Podfile.
|
53
|
-
#
|
54
|
-
def self.default_ld_flags(target, include_objc_flag = false)
|
55
|
-
ld_flags = ''
|
56
|
-
ld_flags << '-ObjC' if include_objc_flag
|
57
|
-
if target.podfile.set_arc_compatibility_flag? &&
|
58
|
-
target.spec_consumers.any?(&:requires_arc?)
|
59
|
-
ld_flags << ' -fobjc-arc'
|
60
|
-
end
|
61
|
-
ld_flags.strip
|
62
|
-
end
|
63
|
-
|
64
|
-
# Configures the given Xcconfig
|
65
|
-
#
|
66
|
-
# @param [Target] target
|
67
|
-
# The root target, may be nil.
|
68
|
-
#
|
69
|
-
# @param [PodTarget] pod_target
|
70
|
-
# The pod target, which holds the list of +Spec::FileAccessor+.
|
71
|
-
#
|
72
|
-
# @param [Xcodeproj::Config] xcconfig
|
73
|
-
# The xcconfig to edit.
|
74
|
-
#
|
75
|
-
# @param [Boolean] include_ld_flags
|
76
|
-
# Indicates whether or not to generate ld flags in addition to compile flags
|
77
|
-
#
|
78
|
-
# @param [Boolean] test_xcconfig
|
79
|
-
# Whether the settings for dependent targets are being generated for a test xcconfig or not.
|
80
|
-
#
|
81
|
-
# @return [void]
|
82
|
-
#
|
83
|
-
def self.add_settings_for_file_accessors_of_target(target, pod_target, xcconfig, include_ld_flags = true, test_xcconfig = false)
|
84
|
-
file_accessors = pod_target.file_accessors
|
85
|
-
file_accessors = file_accessors.reject { |f| f.spec.test_specification? } unless test_xcconfig
|
86
|
-
file_accessors.each do |file_accessor|
|
87
|
-
if target.nil? || !file_accessor.spec.test_specification?
|
88
|
-
XCConfigHelper.add_spec_build_settings_to_xcconfig(file_accessor.spec_consumer, xcconfig) if include_ld_flags
|
89
|
-
XCConfigHelper.add_static_dependency_build_settings(target, pod_target, xcconfig, file_accessor, include_ld_flags)
|
90
|
-
end
|
91
|
-
end
|
92
|
-
XCConfigHelper.add_dynamic_dependency_build_settings(target, pod_target, xcconfig, include_ld_flags, test_xcconfig)
|
93
|
-
if pod_target.requires_frameworks?
|
94
|
-
pod_target.dependent_targets.each do |dependent_target|
|
95
|
-
XCConfigHelper.add_dynamic_dependency_build_settings(target, dependent_target, xcconfig, include_ld_flags, test_xcconfig)
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
# Adds build settings for static vendored frameworks and libraries.
|
101
|
-
#
|
102
|
-
# @param [Target] target
|
103
|
-
# The root target, may be nil.
|
104
|
-
#
|
105
|
-
# @param [PodTarget] pod_target
|
106
|
-
# The pod target, which holds the list of +Spec::FileAccessor+.
|
107
|
-
#
|
108
|
-
# @param [Xcodeproj::Config] xcconfig
|
109
|
-
# The xcconfig to edit.
|
110
|
-
#
|
111
|
-
# @param [Spec::FileAccessor] file_accessor
|
112
|
-
# The file accessor, which holds the list of static frameworks.
|
113
|
-
#
|
114
|
-
# @param [Boolean] include_ld_flags
|
115
|
-
# Indicates whether or not to generate ld flags in addition to compile flags
|
116
|
-
#
|
117
|
-
# @return [void]
|
118
|
-
#
|
119
|
-
def self.add_static_dependency_build_settings(target, pod_target, xcconfig, file_accessor, include_ld_flags)
|
120
|
-
if target.nil? || !file_accessor.spec.test_specification?
|
121
|
-
adds_other_ldflags = include_ld_flags && XCConfigHelper.links_dependency?(target, pod_target)
|
122
|
-
file_accessor.vendored_static_frameworks.each do |vendored_static_framework|
|
123
|
-
XCConfigHelper.add_framework_build_settings(vendored_static_framework, xcconfig, pod_target.sandbox.root, adds_other_ldflags)
|
124
|
-
end
|
125
|
-
file_accessor.vendored_static_libraries.each do |vendored_static_library|
|
126
|
-
XCConfigHelper.add_library_build_settings(vendored_static_library, xcconfig, pod_target.sandbox.root, adds_other_ldflags)
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
# @param [AggregateTarget] aggregate_target
|
132
|
-
# The aggregate target, may be nil.
|
133
|
-
#
|
134
|
-
# @param [PodTarget] pod_target
|
135
|
-
# The pod target to link or not.
|
136
|
-
#
|
137
|
-
# @return [Boolean] Whether static dependency should be added to the 'OTHER_LDFLAGS'
|
138
|
-
# of the aggregate target. Aggregate targets that inherit search paths will only link
|
139
|
-
# if the target has explicitly declared the pod dependency.
|
140
|
-
#
|
141
|
-
def self.links_dependency?(aggregate_target, pod_target)
|
142
|
-
return true if aggregate_target.nil? || aggregate_target.target_definition.inheritance == 'complete'
|
143
|
-
aggregate_target.pod_targets_to_link.include?(pod_target)
|
144
|
-
end
|
145
|
-
|
146
|
-
# Adds build settings for dynamic vendored frameworks and libraries.
|
147
|
-
#
|
148
|
-
# @param [Target] target
|
149
|
-
# The root target, may be nil.
|
150
|
-
#
|
151
|
-
# @param [PodTarget] pod_target
|
152
|
-
# The pod target, which holds the list of +Spec::FileAccessor+.
|
153
|
-
#
|
154
|
-
# @param [Xcodeproj::Config] xcconfig
|
155
|
-
# The xcconfig to edit.
|
156
|
-
#
|
157
|
-
# @param [Boolean] include_ld_flags
|
158
|
-
# Indicates whether or not to generate ld flags in addition to compile flags
|
159
|
-
#
|
160
|
-
# @param [Boolean] test_xcconfig
|
161
|
-
# Whether the settings for dependent targets are being generated for a test xcconfig or not.
|
162
|
-
#
|
163
|
-
# @return [void]
|
164
|
-
#
|
165
|
-
def self.add_dynamic_dependency_build_settings(target, pod_target, xcconfig, include_ld_flags, test_xcconfig)
|
166
|
-
file_accessors = pod_target.file_accessors
|
167
|
-
file_accessors = file_accessors.reject { |f| f.spec.test_specification? } unless test_xcconfig
|
168
|
-
file_accessors.each do |file_accessor|
|
169
|
-
if target.nil? || !file_accessor.spec.test_specification?
|
170
|
-
file_accessor.vendored_dynamic_frameworks.each do |vendored_dynamic_framework|
|
171
|
-
XCConfigHelper.add_framework_build_settings(vendored_dynamic_framework, xcconfig, pod_target.sandbox.root, include_ld_flags)
|
172
|
-
end
|
173
|
-
file_accessor.vendored_dynamic_libraries.each do |vendored_dynamic_library|
|
174
|
-
XCConfigHelper.add_library_build_settings(vendored_dynamic_library, xcconfig, pod_target.sandbox.root, include_ld_flags)
|
175
|
-
end
|
176
|
-
end
|
177
|
-
end
|
178
|
-
end
|
179
|
-
|
180
|
-
# Configures the given Xcconfig according to the build settings of the
|
181
|
-
# given Specification.
|
182
|
-
#
|
183
|
-
# @param [Specification::Consumer] consumer
|
184
|
-
# The consumer of the specification.
|
185
|
-
#
|
186
|
-
# @param [Xcodeproj::Config] xcconfig
|
187
|
-
# The xcconfig to edit.
|
188
|
-
#
|
189
|
-
# @return [void]
|
190
|
-
#
|
191
|
-
def self.add_spec_build_settings_to_xcconfig(consumer, xcconfig)
|
192
|
-
xcconfig.libraries.merge(consumer.libraries)
|
193
|
-
xcconfig.frameworks.merge(consumer.frameworks)
|
194
|
-
xcconfig.weak_frameworks.merge(consumer.weak_frameworks)
|
195
|
-
add_developers_frameworks_if_needed(xcconfig)
|
196
|
-
end
|
197
|
-
|
198
|
-
# Configures the given Xcconfig with the build settings for the given
|
199
|
-
# framework path.
|
200
|
-
#
|
201
|
-
# @param [Pathname] framework_path
|
202
|
-
# The path of the framework.
|
203
|
-
#
|
204
|
-
# @param [Xcodeproj::Config] xcconfig
|
205
|
-
# The xcconfig to edit.
|
206
|
-
#
|
207
|
-
# @param [Pathname] sandbox_root
|
208
|
-
# The path retrieved from Sandbox#root.
|
209
|
-
#
|
210
|
-
# @param [Boolean] include_ld_flags
|
211
|
-
# Indicates whether or not to generate ld flags in addition to compile flags
|
212
|
-
#
|
213
|
-
# @return [void]
|
214
|
-
#
|
215
|
-
def self.add_framework_build_settings(framework_path, xcconfig, sandbox_root, include_ld_flags = true)
|
216
|
-
name = File.basename(framework_path, '.framework')
|
217
|
-
dirname = '${PODS_ROOT}/' + framework_path.dirname.relative_path_from(sandbox_root).to_s
|
218
|
-
build_settings = {
|
219
|
-
'FRAMEWORK_SEARCH_PATHS' => quote([dirname]),
|
220
|
-
}
|
221
|
-
build_settings['OTHER_LDFLAGS'] = "-framework \"#{name}\"" if include_ld_flags
|
222
|
-
xcconfig.merge!(build_settings)
|
223
|
-
end
|
224
|
-
|
225
|
-
# Configures the given Xcconfig with the build settings for the given
|
226
|
-
# library path.
|
227
|
-
#
|
228
|
-
# @param [Pathname] library_path
|
229
|
-
# The path of the library.
|
230
|
-
#
|
231
|
-
# @param [Xcodeproj::Config] xcconfig
|
232
|
-
# The xcconfig to edit.
|
233
|
-
#
|
234
|
-
# @param [Pathname] sandbox_root
|
235
|
-
# The path retrieved from Sandbox#root.
|
236
|
-
#
|
237
|
-
# @param [Boolean] include_ld_flags
|
238
|
-
# Indicates whether or not to generate ld flags in addition to compile flags
|
239
|
-
#
|
240
|
-
# @return [void]
|
241
|
-
#
|
242
|
-
def self.add_library_build_settings(library_path, xcconfig, sandbox_root, include_ld_flags = true)
|
243
|
-
extension = File.extname(library_path)
|
244
|
-
name = File.basename(library_path, extension).sub(/\Alib/, '')
|
245
|
-
dirname = '${PODS_ROOT}/' + library_path.dirname.relative_path_from(sandbox_root).to_s
|
246
|
-
build_settings = {
|
247
|
-
'LIBRARY_SEARCH_PATHS' => quote([dirname]),
|
248
|
-
}
|
249
|
-
build_settings['OTHER_LDFLAGS'] = "-l\"#{name}\"" if include_ld_flags
|
250
|
-
xcconfig.merge!(build_settings)
|
251
|
-
end
|
252
|
-
|
253
|
-
# Add the code signing settings for generated targets to ensure that
|
254
|
-
# frameworks are correctly signed to be integrated and re-signed when
|
255
|
-
# building the application and embedding the framework
|
256
|
-
#
|
257
|
-
# @param [Target] target
|
258
|
-
# The target.
|
259
|
-
#
|
260
|
-
# @param [Xcodeproj::Config] xcconfig
|
261
|
-
# The xcconfig to edit.
|
262
|
-
#
|
263
|
-
# @return [void]
|
264
|
-
#
|
265
|
-
def self.add_code_signing_settings(target, xcconfig)
|
266
|
-
build_settings = {}
|
267
|
-
if target.platform.to_sym == :osx
|
268
|
-
build_settings['CODE_SIGN_IDENTITY'] = ''
|
269
|
-
end
|
270
|
-
xcconfig.merge!(build_settings)
|
271
|
-
end
|
272
|
-
|
273
|
-
# Checks if the given target requires specific settings and configures
|
274
|
-
# the given Xcconfig.
|
275
|
-
#
|
276
|
-
# @param [Target] target
|
277
|
-
# The target.
|
278
|
-
#
|
279
|
-
# @param [Xcodeproj::Config] xcconfig
|
280
|
-
# The xcconfig to edit.
|
281
|
-
#
|
282
|
-
# @return [void]
|
283
|
-
#
|
284
|
-
def self.add_target_specific_settings(target, xcconfig)
|
285
|
-
if target.requires_frameworks?
|
286
|
-
add_code_signing_settings(target, xcconfig)
|
287
|
-
end
|
288
|
-
add_language_specific_settings(target, xcconfig)
|
289
|
-
end
|
290
|
-
|
291
|
-
# Returns the search paths for frameworks and libraries the given target
|
292
|
-
# depends on, so that it can be correctly built and linked.
|
293
|
-
#
|
294
|
-
# @param [Target] target
|
295
|
-
# The target.
|
296
|
-
#
|
297
|
-
# @param [Array<PodTarget>] dependent_targets
|
298
|
-
# The pod targets the given target depends on.
|
299
|
-
#
|
300
|
-
# @param [Boolean] test_xcconfig
|
301
|
-
# Whether the settings for dependent targets are being generated for a test xcconfig or not.
|
302
|
-
#
|
303
|
-
# @return [Hash<String, String>] the settings
|
304
|
-
#
|
305
|
-
def self.search_paths_for_dependent_targets(target, dependent_targets, test_xcconfig = false)
|
306
|
-
dependent_targets = dependent_targets.select(&:should_build?)
|
307
|
-
|
308
|
-
# Filter out dependent targets that are subsets of another target.
|
309
|
-
subset_targets = []
|
310
|
-
dependent_targets.uniq.combination(2) do |a, b|
|
311
|
-
if (a.specs - b.specs).empty?
|
312
|
-
subset_targets << a
|
313
|
-
elsif (b.specs - a.specs).empty?
|
314
|
-
subset_targets << b
|
315
|
-
end
|
316
|
-
end
|
317
|
-
dependent_targets -= subset_targets
|
318
|
-
|
319
|
-
# Alias build dirs to avoid recursive definitions for pod targets and depending
|
320
|
-
# on build settings which could be overwritten in the user target.
|
321
|
-
build_settings = {
|
322
|
-
BUILD_DIR_VARIABLE[2..-2] => '${BUILD_DIR}',
|
323
|
-
CONFIGURATION_BUILD_DIR_VARIABLE[2..-2] => "#{BUILD_DIR_VARIABLE}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)",
|
324
|
-
}
|
325
|
-
|
326
|
-
# Scope pod targets as long as they are not test targets.
|
327
|
-
if !test_xcconfig && target.respond_to?(:configuration_build_dir)
|
328
|
-
build_settings['CONFIGURATION_BUILD_DIR'] = target.configuration_build_dir(CONFIGURATION_BUILD_DIR_VARIABLE)
|
329
|
-
end
|
330
|
-
|
331
|
-
module_map_files = []
|
332
|
-
unless dependent_targets.empty?
|
333
|
-
framework_search_paths = []
|
334
|
-
library_search_paths = []
|
335
|
-
swift_import_paths = []
|
336
|
-
dependent_targets.each do |dependent_target|
|
337
|
-
if dependent_target.requires_frameworks?
|
338
|
-
framework_search_paths << dependent_target.configuration_build_dir(CONFIGURATION_BUILD_DIR_VARIABLE)
|
339
|
-
else
|
340
|
-
library_search_paths << dependent_target.configuration_build_dir(CONFIGURATION_BUILD_DIR_VARIABLE)
|
341
|
-
if dependent_target.defines_module?
|
342
|
-
module_map_file = if dependent_target.uses_swift?
|
343
|
-
# for swift, we have a custom build phase that copies in the module map, appending the .Swift module
|
344
|
-
"${PODS_CONFIGURATION_BUILD_DIR}/#{dependent_target.label}/#{dependent_target.product_module_name}.modulemap"
|
345
|
-
else
|
346
|
-
"${PODS_ROOT}/#{dependent_target.module_map_path.relative_path_from(dependent_target.sandbox.root)}"
|
347
|
-
end
|
348
|
-
module_map_files << %(-fmodule-map-file="#{module_map_file}")
|
349
|
-
swift_import_paths << dependent_target.configuration_build_dir(CONFIGURATION_BUILD_DIR_VARIABLE) if dependent_target.uses_swift?
|
350
|
-
end
|
351
|
-
end
|
352
|
-
end
|
353
|
-
|
354
|
-
build_settings['FRAMEWORK_SEARCH_PATHS'] = XCConfigHelper.quote(framework_search_paths.uniq)
|
355
|
-
build_settings['LIBRARY_SEARCH_PATHS'] = XCConfigHelper.quote(library_search_paths.uniq)
|
356
|
-
build_settings['SWIFT_INCLUDE_PATHS'] = XCConfigHelper.quote(swift_import_paths.uniq)
|
357
|
-
end
|
358
|
-
|
359
|
-
other_swift_flags = module_map_files.tap(&:uniq!).flat_map { |f| ['-Xcc', f] }
|
360
|
-
if target.is_a?(PodTarget) && !target.requires_frameworks? && target.defines_module? && !test_xcconfig
|
361
|
-
# make it possible for a mixed swift/objc static library to be able to import the objc from within swift
|
362
|
-
other_swift_flags += ['-import-underlying-module', '-Xcc', '-fmodule-map-file="${SRCROOT}/${MODULEMAP_FILE}"']
|
363
|
-
end
|
364
|
-
# unconditionally set these, because of (the possibility of) having to add the pod targets own module map file
|
365
|
-
build_settings['OTHER_CFLAGS'] = module_map_files.join(' ')
|
366
|
-
build_settings['OTHER_SWIFT_FLAGS'] = other_swift_flags.join(' ')
|
367
|
-
|
368
|
-
build_settings
|
369
|
-
end
|
370
|
-
|
371
|
-
# Updates xcconfig with the HEADER_SEARCH_PATHS from the search_paths.
|
372
|
-
#
|
373
|
-
# @param [Target] search_paths_target
|
374
|
-
# The target.
|
375
|
-
#
|
376
|
-
# @param [Xcodeproj::Config] xcconfig
|
377
|
-
# The xcconfig to edit.
|
378
|
-
#
|
379
|
-
def self.propagate_header_search_paths_from_search_paths(search_paths_target, xcconfig)
|
380
|
-
header_search_paths_list = []
|
381
|
-
search_paths_target.pod_targets.each do |target|
|
382
|
-
target.spec_consumers.each do |spec_consumer|
|
383
|
-
paths = spec_consumer.user_target_xcconfig['HEADER_SEARCH_PATHS']
|
384
|
-
header_search_paths_list <<= paths unless paths.nil?
|
385
|
-
end
|
386
|
-
unless header_search_paths_list == []
|
387
|
-
header_search_paths = header_search_paths_list.join(' ')
|
388
|
-
unless header_search_paths.include? '$(inherited)'
|
389
|
-
header_search_paths = '$(inherited) ' + header_search_paths
|
390
|
-
end
|
391
|
-
build_settings = { 'HEADER_SEARCH_PATHS' => header_search_paths }
|
392
|
-
xcconfig.merge!(build_settings)
|
393
|
-
end
|
394
|
-
end
|
395
|
-
end
|
396
|
-
|
397
|
-
# Add custom build settings and required build settings to link to
|
398
|
-
# vendored libraries and frameworks.
|
399
|
-
#
|
400
|
-
# @param [Target] target
|
401
|
-
# The root target, may be nil.
|
402
|
-
#
|
403
|
-
# @param [Array<PodTarget] dep_targets
|
404
|
-
# The dependency targets to add the vendored build settings for.
|
405
|
-
#
|
406
|
-
# @param [Xcodeproj::Config] xcconfig
|
407
|
-
# The xcconfig to edit.
|
408
|
-
#
|
409
|
-
# @param [Boolean] include_ld_flags
|
410
|
-
# Indicates whether or not to generate ld flags in addition to compile flags
|
411
|
-
#
|
412
|
-
# @param [Boolean] test_xcconfig
|
413
|
-
# Indicates whether or not the generated ld flags are for a test xcconfig or not
|
414
|
-
#
|
415
|
-
# @note
|
416
|
-
# In case of generated pod targets, which require frameworks, the
|
417
|
-
# vendored frameworks and libraries are already linked statically
|
418
|
-
# into the framework binary and must not be linked again to the
|
419
|
-
# user target.
|
420
|
-
#
|
421
|
-
def self.generate_vendored_build_settings(target, dep_targets, xcconfig, include_ld_flags = true, test_xcconfig = false)
|
422
|
-
dep_targets.each do |dep_target|
|
423
|
-
unless dep_target.should_build? && dep_target.requires_frameworks? && !dep_target.static_framework?
|
424
|
-
XCConfigHelper.add_settings_for_file_accessors_of_target(target, dep_target, xcconfig, include_ld_flags, test_xcconfig)
|
425
|
-
end
|
426
|
-
end
|
427
|
-
end
|
428
|
-
|
429
|
-
# Ensure to add the default linker run path search paths as they could
|
430
|
-
# be not present due to being historically absent in the project or
|
431
|
-
# target template or just being removed by being superficial when
|
432
|
-
# linking third-party dependencies exclusively statically. This is not
|
433
|
-
# something a project needs specifically for the integration with
|
434
|
-
# CocoaPods, but makes sure that it is self-contained for the given
|
435
|
-
# constraints.
|
436
|
-
#
|
437
|
-
# @param [Target] target
|
438
|
-
# The target, this can be an aggregate target or a pod target.
|
439
|
-
#
|
440
|
-
# @param [Boolean] requires_host_target
|
441
|
-
# If this target requires a host target
|
442
|
-
#
|
443
|
-
# @param [Boolean] test_bundle
|
444
|
-
# Whether this is a test bundle or not. This has an effect when the platform is `osx` and changes
|
445
|
-
# the runtime search paths accordingly.
|
446
|
-
#
|
447
|
-
# @param [Xcodeproj::Config] xcconfig
|
448
|
-
# The xcconfig to edit.
|
449
|
-
#
|
450
|
-
# @return [void]
|
451
|
-
#
|
452
|
-
def self.generate_ld_runpath_search_paths(target, requires_host_target, test_bundle, xcconfig)
|
453
|
-
ld_runpath_search_paths = ['$(inherited)']
|
454
|
-
if target.platform.symbolic_name == :osx
|
455
|
-
ld_runpath_search_paths << "'@executable_path/../Frameworks'"
|
456
|
-
ld_runpath_search_paths << \
|
457
|
-
if test_bundle
|
458
|
-
"'@loader_path/../Frameworks'"
|
459
|
-
else
|
460
|
-
"'@loader_path/Frameworks'"
|
461
|
-
end
|
462
|
-
else
|
463
|
-
ld_runpath_search_paths << [
|
464
|
-
"'@executable_path/Frameworks'",
|
465
|
-
"'@loader_path/Frameworks'",
|
466
|
-
]
|
467
|
-
ld_runpath_search_paths << "'@executable_path/../../Frameworks'" if requires_host_target
|
468
|
-
end
|
469
|
-
xcconfig.merge!('LD_RUNPATH_SEARCH_PATHS' => ld_runpath_search_paths.join(' '))
|
470
|
-
end
|
471
|
-
|
472
|
-
# Add pod target to list of frameworks / libraries that are linked
|
473
|
-
# with the user’s project.
|
474
|
-
#
|
475
|
-
# @param [AggregateTarget] aggregate_target
|
476
|
-
# The aggregate target, may be nil.
|
477
|
-
#
|
478
|
-
# @param [Array<PodTarget] pod_targets
|
479
|
-
# The pod targets to add the vendored build settings for.
|
480
|
-
#
|
481
|
-
# @param [Xcodeproj::Config] xcconfig
|
482
|
-
# The xcconfig to edit.
|
483
|
-
#
|
484
|
-
# @return [void]
|
485
|
-
#
|
486
|
-
def self.generate_other_ld_flags(aggregate_target, pod_targets, xcconfig)
|
487
|
-
# Make sure -framework option gets added for the search paths when static_frameworks are involved.
|
488
|
-
# Otherwise test targets won't link in their primary target's dependencies.
|
489
|
-
unless aggregate_target.nil?
|
490
|
-
dependent_targets = aggregate_target.search_paths_aggregate_targets
|
491
|
-
dependent_targets.each do |dependent_target|
|
492
|
-
if aggregate_target.requires_frameworks? && dependent_target.pod_targets.any?(&:static_framework?)
|
493
|
-
generate_other_ld_flags(dependent_target, dependent_target.pod_targets, xcconfig)
|
494
|
-
end
|
495
|
-
end
|
496
|
-
end
|
497
|
-
other_ld_flags = pod_targets.select(&:should_build?).map do |pod_target|
|
498
|
-
if pod_target.requires_frameworks?
|
499
|
-
%(-framework "#{pod_target.product_basename}")
|
500
|
-
elsif XCConfigHelper.links_dependency?(aggregate_target, pod_target)
|
501
|
-
%(-l "#{pod_target.product_basename}")
|
502
|
-
end
|
503
|
-
end
|
504
|
-
xcconfig.merge!('OTHER_LDFLAGS' => other_ld_flags.compact.join(' '))
|
505
|
-
end
|
506
|
-
|
507
|
-
# Checks if the given target requires language specific settings and
|
508
|
-
# configures the given Xcconfig.
|
509
|
-
#
|
510
|
-
# @param [Target] target
|
511
|
-
# The target.
|
512
|
-
#
|
513
|
-
# @param [Xcodeproj::Config] xcconfig
|
514
|
-
# The xcconfig to edit.
|
515
|
-
#
|
516
|
-
# @return [void]
|
517
|
-
#
|
518
|
-
def self.add_language_specific_settings(target, xcconfig)
|
519
|
-
if target.uses_swift?
|
520
|
-
other_swift_flags = ['$(inherited)', quote(%w(-D COCOAPODS))]
|
521
|
-
other_swift_flags << quote(%w(-suppress-warnings)) if target.try(:inhibit_warnings?)
|
522
|
-
build_settings = { 'OTHER_SWIFT_FLAGS' => other_swift_flags.join(' ') }
|
523
|
-
xcconfig.merge!(build_settings)
|
524
|
-
end
|
525
|
-
end
|
526
|
-
|
527
|
-
# Adds the search paths of the developer frameworks to the specification
|
528
|
-
# if needed. This is done because the `SenTestingKit` requires them and
|
529
|
-
# adding them to each specification which requires it is repetitive and
|
530
|
-
# error prone.
|
531
|
-
#
|
532
|
-
# @param [Xcodeproj::Config] xcconfig
|
533
|
-
# The xcconfig to edit.
|
534
|
-
#
|
535
|
-
# @return [void]
|
536
|
-
#
|
537
|
-
def self.add_developers_frameworks_if_needed(xcconfig)
|
538
|
-
matched_frameworks = xcconfig.frameworks & %w(XCTest SenTestingKit)
|
539
|
-
unless matched_frameworks.empty?
|
540
|
-
search_paths = xcconfig.attributes['FRAMEWORK_SEARCH_PATHS'] ||= ''
|
541
|
-
search_paths_to_add = []
|
542
|
-
search_paths_to_add << '$(inherited)'
|
543
|
-
frameworks_path = '"$(PLATFORM_DIR)/Developer/Library/Frameworks"'
|
544
|
-
search_paths_to_add << frameworks_path
|
545
|
-
search_paths_to_add.each do |search_path|
|
546
|
-
unless search_paths.include?(search_path)
|
547
|
-
search_paths << ' ' unless search_paths.empty?
|
548
|
-
search_paths << search_path
|
549
|
-
end
|
550
|
-
end
|
551
|
-
end
|
552
|
-
end
|
553
|
-
|
554
|
-
#---------------------------------------------------------------------#
|
555
|
-
end
|
556
|
-
end
|
557
|
-
end
|
558
|
-
end
|