cocoapods 1.5.2 → 1.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +365 -1
- data/bin/pod +1 -1
- data/lib/cocoapods/command/cache/clean.rb +1 -1
- data/lib/cocoapods/command/init.rb +4 -2
- data/lib/cocoapods/command/install.rb +7 -0
- data/lib/cocoapods/command/lib/lint.rb +8 -1
- data/lib/cocoapods/command/outdated.rb +4 -9
- 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/command.rb +3 -1
- data/lib/cocoapods/config.rb +13 -2
- data/lib/cocoapods/downloader/cache.rb +1 -1
- data/lib/cocoapods/executable.rb +3 -3
- data/lib/cocoapods/external_sources/abstract_external_source.rb +23 -13
- data/lib/cocoapods/external_sources.rb +7 -4
- data/lib/cocoapods/gem_version.rb +1 -1
- data/lib/cocoapods/generator/acknowledgements/markdown.rb +6 -0
- data/lib/cocoapods/generator/acknowledgements/plist.rb +13 -2
- data/lib/cocoapods/generator/app_target_helper.rb +141 -17
- data/lib/cocoapods/generator/copy_resources_script.rb +14 -3
- data/lib/cocoapods/generator/dummy_source.rb +14 -5
- data/lib/cocoapods/generator/embed_frameworks_script.rb +37 -20
- 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/analyzer/analysis_result.rb +52 -22
- data/lib/cocoapods/installer/analyzer/locking_dependency_analyzer.rb +14 -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 +27 -14
- data/lib/cocoapods/installer/analyzer/target_inspector.rb +17 -11
- data/lib/cocoapods/installer/analyzer.rb +391 -284
- data/lib/cocoapods/installer/installation_options.rb +2 -0
- data/lib/cocoapods/installer/pod_source_installer.rb +31 -43
- data/lib/cocoapods/installer/post_install_hooks_context.rb +72 -47
- 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/target_integrator/xcconfig_integrator.rb +44 -11
- data/lib/cocoapods/installer/user_project_integrator/target_integrator.rb +69 -29
- data/lib/cocoapods/installer/user_project_integrator.rb +6 -4
- 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 +104 -0
- data/lib/cocoapods/installer/xcode/pods_project_generator/file_references_installer.rb +23 -50
- data/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_installer.rb +296 -177
- data/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_integrator.rb +51 -33
- 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 +62 -69
- data/lib/cocoapods/installer/xcode/pods_project_generator/target_installer_helper.rb +72 -0
- data/lib/cocoapods/installer/xcode/pods_project_generator.rb +130 -122
- data/lib/cocoapods/installer/xcode/target_validator.rb +15 -9
- data/lib/cocoapods/installer.rb +140 -63
- data/lib/cocoapods/project.rb +16 -14
- data/lib/cocoapods/resolver/resolver_specification.rb +41 -0
- data/lib/cocoapods/resolver.rb +79 -98
- 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/sandbox.rb +31 -43
- data/lib/cocoapods/sources_manager.rb +1 -1
- data/lib/cocoapods/target/aggregate_target.rb +143 -85
- data/lib/cocoapods/target/build_settings.rb +1124 -0
- data/lib/cocoapods/target/framework_paths.rb +36 -0
- data/lib/cocoapods/target/pod_target.rb +198 -295
- data/lib/cocoapods/target.rb +92 -37
- data/lib/cocoapods/user_interface.rb +5 -0
- data/lib/cocoapods/validator.rb +149 -44
- data/lib/cocoapods.rb +0 -1
- metadata +31 -23
- 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
- data/lib/cocoapods/generator/xcconfig.rb +0 -13
@@ -0,0 +1,1124 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
class Target
|
5
|
+
# @since 1.5.0
|
6
|
+
class BuildSettings
|
7
|
+
#-------------------------------------------------------------------------#
|
8
|
+
|
9
|
+
# @!group Constants
|
10
|
+
|
11
|
+
# @return [Set<String>]
|
12
|
+
# The build settings that should be treated as arrays, rather than strings.
|
13
|
+
#
|
14
|
+
PLURAL_SETTINGS = %w(
|
15
|
+
ALTERNATE_PERMISSIONS_FILES
|
16
|
+
ARCHS
|
17
|
+
BUILD_VARIANTS
|
18
|
+
EXCLUDED_SOURCE_FILE_NAMES
|
19
|
+
FRAMEWORK_SEARCH_PATHS
|
20
|
+
GCC_PREPROCESSOR_DEFINITIONS
|
21
|
+
GCC_PREPROCESSOR_DEFINITIONS_NOT_USED_IN_PRECOMPS
|
22
|
+
HEADER_SEARCH_PATHS
|
23
|
+
INFOPLIST_PREPROCESSOR_DEFINITIONS
|
24
|
+
LD_RUNPATH_SEARCH_PATHS
|
25
|
+
LIBRARY_SEARCH_PATHS
|
26
|
+
OTHER_CFLAGS
|
27
|
+
OTHER_CPLUSPLUSFLAGS
|
28
|
+
OTHER_LDFLAGS
|
29
|
+
OTHER_SWIFT_FLAGS
|
30
|
+
REZ_SEARCH_PATHS
|
31
|
+
SECTORDER_FLAGS
|
32
|
+
SWIFT_ACTIVE_COMPILATION_CONDITIONS
|
33
|
+
SWIFT_INCLUDE_PATHS
|
34
|
+
WARNING_CFLAGS
|
35
|
+
WARNING_LDFLAGS
|
36
|
+
).to_set.freeze
|
37
|
+
|
38
|
+
# @return [String]
|
39
|
+
# The variable for the configuration build directory used when building pod targets.
|
40
|
+
#
|
41
|
+
CONFIGURATION_BUILD_DIR_VARIABLE = '${PODS_CONFIGURATION_BUILD_DIR}'.freeze
|
42
|
+
|
43
|
+
#-------------------------------------------------------------------------#
|
44
|
+
|
45
|
+
# @!group DSL
|
46
|
+
|
47
|
+
# Creates a method that calculates a part of the build settings for the {#target}.
|
48
|
+
#
|
49
|
+
# @!visibility private
|
50
|
+
#
|
51
|
+
# @param [Symbol,String] method_name
|
52
|
+
# The name of the method to define
|
53
|
+
#
|
54
|
+
# @param [Boolean] build_setting
|
55
|
+
# Whether the method name should be added (upcased) to {.build_setting_names}
|
56
|
+
#
|
57
|
+
# @param [Boolean] memoized
|
58
|
+
# Whether the method should be memoized
|
59
|
+
#
|
60
|
+
# @param [Boolean] sorted
|
61
|
+
# Whether the return value should be sorted
|
62
|
+
#
|
63
|
+
# @param [Boolean] uniqued
|
64
|
+
# Whether the return value should be uniqued
|
65
|
+
#
|
66
|
+
# @param [Boolean] compacted
|
67
|
+
# Whether the return value should be compacted
|
68
|
+
#
|
69
|
+
# @param [Boolean] frozen
|
70
|
+
# Whether the return value should be frozen
|
71
|
+
#
|
72
|
+
# @param [Boolean, Symbol] from_search_paths_aggregate_targets
|
73
|
+
# If truthy, the method from {Aggregate} that should be used to concatenate build settings from
|
74
|
+
# {::Pod::AggregateTarget#search_paths_aggregate_target}
|
75
|
+
#
|
76
|
+
# @param [Symbol] from_pod_targets_to_link
|
77
|
+
# If truthy, the `_to_import` values from `BuildSettings#pod_targets_to_link` will be concatenated
|
78
|
+
#
|
79
|
+
# @param [Block] implementation
|
80
|
+
#
|
81
|
+
# @macro [attach] define_build_settings_method
|
82
|
+
# @!method $1
|
83
|
+
#
|
84
|
+
# The `$1` build setting for the {#target}.
|
85
|
+
#
|
86
|
+
# The return value from this method will be: `${1--1}`.
|
87
|
+
#
|
88
|
+
def self.define_build_settings_method(method_name, build_setting: false,
|
89
|
+
memoized: false, sorted: false, uniqued: false, compacted: false, frozen: true,
|
90
|
+
from_search_paths_aggregate_targets: false, from_pod_targets_to_link: false,
|
91
|
+
&implementation)
|
92
|
+
|
93
|
+
memoized_key = "#{self}##{method_name}".freeze
|
94
|
+
|
95
|
+
(@build_settings_names ||= Set.new) << method_name.to_s.upcase if build_setting
|
96
|
+
|
97
|
+
raw_method_name = :"_raw_#{method_name}"
|
98
|
+
define_method(raw_method_name, &implementation)
|
99
|
+
private(raw_method_name)
|
100
|
+
|
101
|
+
dup_before_freeze = frozen && (from_pod_targets_to_link || from_search_paths_aggregate_targets || uniqued || sorted)
|
102
|
+
|
103
|
+
define_method(method_name) do
|
104
|
+
if memoized
|
105
|
+
retval = @__memoized.fetch(memoized_key, :not_found)
|
106
|
+
return retval if :not_found != retval
|
107
|
+
end
|
108
|
+
|
109
|
+
retval = send(raw_method_name)
|
110
|
+
if retval.nil?
|
111
|
+
@__memoized[memoized_key] = retval if memoized
|
112
|
+
return
|
113
|
+
end
|
114
|
+
|
115
|
+
retval = retval.dup if dup_before_freeze && retval.frozen?
|
116
|
+
|
117
|
+
retval.concat(pod_targets_to_link.flat_map { |pod_target| pod_target.build_settings.public_send("#{method_name}_to_import") }) if from_pod_targets_to_link
|
118
|
+
retval.concat(search_paths_aggregate_target_pod_target_build_settings.flat_map(&from_search_paths_aggregate_targets)) if from_search_paths_aggregate_targets
|
119
|
+
|
120
|
+
retval.compact! if compacted
|
121
|
+
retval.uniq! if uniqued
|
122
|
+
retval.sort! if sorted
|
123
|
+
retval.freeze if frozen
|
124
|
+
|
125
|
+
@__memoized[memoized_key] = retval if memoized
|
126
|
+
|
127
|
+
retval
|
128
|
+
end
|
129
|
+
end
|
130
|
+
private_class_method :define_build_settings_method
|
131
|
+
|
132
|
+
class << self
|
133
|
+
#-------------------------------------------------------------------------#
|
134
|
+
|
135
|
+
# @!group Public API
|
136
|
+
|
137
|
+
# @return [Set<String>] a set of all the build settings names that will
|
138
|
+
# be present in the #xcconfig
|
139
|
+
#
|
140
|
+
attr_reader :build_settings_names
|
141
|
+
end
|
142
|
+
|
143
|
+
#-------------------------------------------------------------------------#
|
144
|
+
|
145
|
+
# @!group Public API
|
146
|
+
|
147
|
+
# @return [Target]
|
148
|
+
# The target this build settings object is generating build settings for
|
149
|
+
#
|
150
|
+
attr_reader :target
|
151
|
+
|
152
|
+
# Initialize a new instance
|
153
|
+
#
|
154
|
+
# @param [Target] target
|
155
|
+
# see {#target}
|
156
|
+
#
|
157
|
+
def initialize(target)
|
158
|
+
@target = target
|
159
|
+
@__memoized = {}
|
160
|
+
end
|
161
|
+
|
162
|
+
def initialize_copy(other)
|
163
|
+
super
|
164
|
+
@__memoized = {}
|
165
|
+
end
|
166
|
+
|
167
|
+
# @return [Xcodeproj::Config]
|
168
|
+
define_build_settings_method :xcconfig, :memoized => true do
|
169
|
+
settings = add_inherited_to_plural(to_h)
|
170
|
+
Xcodeproj::Config.new(settings)
|
171
|
+
end
|
172
|
+
|
173
|
+
alias generate xcconfig
|
174
|
+
|
175
|
+
# Saves the generated xcconfig to the given path
|
176
|
+
#
|
177
|
+
# @return [Xcodeproj::Config]
|
178
|
+
#
|
179
|
+
# @see #xcconfig
|
180
|
+
#
|
181
|
+
# @param [String,Pathname] path
|
182
|
+
# The path the xcconfig will be saved to
|
183
|
+
#
|
184
|
+
def save_as(path)
|
185
|
+
xcconfig.save_as(path)
|
186
|
+
end
|
187
|
+
|
188
|
+
#-------------------------------------------------------------------------#
|
189
|
+
|
190
|
+
# @!group Paths
|
191
|
+
|
192
|
+
# @return [String]
|
193
|
+
define_build_settings_method :pods_build_dir, :build_setting => true do
|
194
|
+
'${BUILD_DIR}'
|
195
|
+
end
|
196
|
+
|
197
|
+
# @return [String]
|
198
|
+
define_build_settings_method :pods_configuration_build_dir, :build_setting => true do
|
199
|
+
'${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)'
|
200
|
+
end
|
201
|
+
|
202
|
+
#-------------------------------------------------------------------------#
|
203
|
+
|
204
|
+
# @!group Code Signing
|
205
|
+
|
206
|
+
# @return [String]
|
207
|
+
define_build_settings_method :code_sign_identity, :build_setting => true do
|
208
|
+
return unless target.requires_frameworks?
|
209
|
+
return unless target.platform.to_sym == :osx
|
210
|
+
''
|
211
|
+
end
|
212
|
+
|
213
|
+
#-------------------------------------------------------------------------#
|
214
|
+
|
215
|
+
# @!group Frameworks
|
216
|
+
|
217
|
+
# @return [Array<String>]
|
218
|
+
define_build_settings_method :frameworks do
|
219
|
+
[]
|
220
|
+
end
|
221
|
+
|
222
|
+
# @return [Array<String>]
|
223
|
+
define_build_settings_method :weak_frameworks do
|
224
|
+
[]
|
225
|
+
end
|
226
|
+
|
227
|
+
# @return [Array<String>]
|
228
|
+
define_build_settings_method :framework_search_paths, :build_setting => true, :memoized => true do
|
229
|
+
framework_search_paths_to_import_developer_frameworks(frameworks)
|
230
|
+
end
|
231
|
+
|
232
|
+
# @param [Array<String>] frameworks
|
233
|
+
# The list of framework names
|
234
|
+
#
|
235
|
+
# @return [Array<String>]
|
236
|
+
# the `FRAMEWORK_SEARCH_PATHS` needed to import developer frameworks
|
237
|
+
def framework_search_paths_to_import_developer_frameworks(frameworks)
|
238
|
+
if frameworks.include?('XCTest') || frameworks.include?('SenTestingKit')
|
239
|
+
%w[ $(PLATFORM_DIR)/Developer/Library/Frameworks ]
|
240
|
+
else
|
241
|
+
[]
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
#-------------------------------------------------------------------------#
|
246
|
+
|
247
|
+
# @!group Libraries
|
248
|
+
|
249
|
+
# @return [Array<String>]
|
250
|
+
define_build_settings_method :libraries do
|
251
|
+
[]
|
252
|
+
end
|
253
|
+
|
254
|
+
#-------------------------------------------------------------------------#
|
255
|
+
|
256
|
+
# @!group Clang
|
257
|
+
|
258
|
+
# @return [Array<String>]
|
259
|
+
define_build_settings_method :gcc_preprocessor_definitions, :build_setting => true do
|
260
|
+
%w( COCOAPODS=1 )
|
261
|
+
end
|
262
|
+
|
263
|
+
# @return [Array<String>]
|
264
|
+
define_build_settings_method :other_cflags, :build_setting => true, :memoized => true do
|
265
|
+
module_map_files.map { |f| "-fmodule-map-file=#{f}" }
|
266
|
+
end
|
267
|
+
|
268
|
+
# @return [Array<String>]
|
269
|
+
define_build_settings_method :module_map_files do
|
270
|
+
[]
|
271
|
+
end
|
272
|
+
|
273
|
+
#-------------------------------------------------------------------------#
|
274
|
+
|
275
|
+
# @!group Swift
|
276
|
+
|
277
|
+
# @return [Boolean]
|
278
|
+
# Whether `OTHER_SWIFT_FLAGS` should be generated when the target
|
279
|
+
# does not use swift.
|
280
|
+
#
|
281
|
+
def other_swift_flags_without_swift?
|
282
|
+
false
|
283
|
+
end
|
284
|
+
|
285
|
+
# @return [Array<String>]
|
286
|
+
define_build_settings_method :other_swift_flags, :build_setting => true, :memoized => true do
|
287
|
+
return unless target.uses_swift? || other_swift_flags_without_swift?
|
288
|
+
flags = %w(-D COCOAPODS)
|
289
|
+
flags.concat module_map_files.flat_map { |f| ['-Xcc', "-fmodule-map-file=#{f}"] }
|
290
|
+
flags
|
291
|
+
end
|
292
|
+
|
293
|
+
#-------------------------------------------------------------------------#
|
294
|
+
|
295
|
+
# @!group Linking
|
296
|
+
|
297
|
+
# @return [Boolean]
|
298
|
+
define_build_settings_method :requires_objc_linker_flag? do
|
299
|
+
false
|
300
|
+
end
|
301
|
+
|
302
|
+
# @return [Boolean]
|
303
|
+
define_build_settings_method :requires_fobjc_arc? do
|
304
|
+
false
|
305
|
+
end
|
306
|
+
|
307
|
+
# @return [Array<String>]
|
308
|
+
# the `LD_RUNPATH_SEARCH_PATHS` needed for dynamically linking the {#target}
|
309
|
+
#
|
310
|
+
# @param [Boolean] requires_host_target
|
311
|
+
#
|
312
|
+
# @param [Boolean] test_bundle
|
313
|
+
#
|
314
|
+
def _ld_runpath_search_paths(requires_host_target: false, test_bundle: false)
|
315
|
+
if target.platform.symbolic_name == :osx
|
316
|
+
["'@executable_path/../Frameworks'",
|
317
|
+
test_bundle ? "'@loader_path/../Frameworks'" : "'@loader_path/Frameworks'"]
|
318
|
+
else
|
319
|
+
paths = [
|
320
|
+
"'@executable_path/Frameworks'",
|
321
|
+
"'@loader_path/Frameworks'",
|
322
|
+
]
|
323
|
+
paths << "'@executable_path/../../Frameworks'" if requires_host_target
|
324
|
+
paths
|
325
|
+
end
|
326
|
+
end
|
327
|
+
private :_ld_runpath_search_paths
|
328
|
+
|
329
|
+
# @return [Array<String>]
|
330
|
+
define_build_settings_method :other_ldflags, :build_setting => true, :memoized => true do
|
331
|
+
ld_flags = []
|
332
|
+
ld_flags << '-ObjC' if requires_objc_linker_flag?
|
333
|
+
if requires_fobjc_arc?
|
334
|
+
ld_flags << '-fobjc-arc'
|
335
|
+
end
|
336
|
+
libraries.each { |l| ld_flags << %(-l"#{l}") }
|
337
|
+
frameworks.each { |f| ld_flags << '-framework' << %("#{f}") }
|
338
|
+
weak_frameworks.each { |f| ld_flags << '-weak_framework' << %("#{f}") }
|
339
|
+
ld_flags
|
340
|
+
end
|
341
|
+
|
342
|
+
#-------------------------------------------------------------------------#
|
343
|
+
|
344
|
+
# @!group Private Methods
|
345
|
+
|
346
|
+
private
|
347
|
+
|
348
|
+
# @return [Hash<String => String|Array<String>>]
|
349
|
+
def to_h
|
350
|
+
hash = {}
|
351
|
+
self.class.build_settings_names.sort.each do |setting|
|
352
|
+
hash[setting] = public_send(setting.downcase)
|
353
|
+
end
|
354
|
+
hash
|
355
|
+
end
|
356
|
+
|
357
|
+
# @return [Hash<String => String>]
|
358
|
+
def add_inherited_to_plural(hash)
|
359
|
+
Hash[hash.map do |key, value|
|
360
|
+
next [key, '$(inherited)'] if value.nil?
|
361
|
+
if PLURAL_SETTINGS.include?(key)
|
362
|
+
raise ArgumentError, "#{key} is a plural setting, cannot have #{value.inspect} as its value" unless value.is_a? Array
|
363
|
+
|
364
|
+
value = "$(inherited) #{quote_array(value)}"
|
365
|
+
else
|
366
|
+
raise ArgumentError, "#{key} is not a plural setting, cannot have #{value.inspect} as its value" unless value.is_a? String
|
367
|
+
end
|
368
|
+
|
369
|
+
[key, value]
|
370
|
+
end]
|
371
|
+
end
|
372
|
+
|
373
|
+
# @return [Array<String>]
|
374
|
+
#
|
375
|
+
# @param [Array<String>] array
|
376
|
+
#
|
377
|
+
def quote_array(array)
|
378
|
+
array.map do |element|
|
379
|
+
case element
|
380
|
+
when /\A([\w-]+?)=(.+)\z/
|
381
|
+
key = Regexp.last_match(1)
|
382
|
+
value = Regexp.last_match(2)
|
383
|
+
value = %("#{value}") if value =~ /[^\w\d]/
|
384
|
+
%(#{key}=#{value})
|
385
|
+
when /[\$\[\]\ ]/
|
386
|
+
%("#{element}")
|
387
|
+
else
|
388
|
+
element
|
389
|
+
end
|
390
|
+
end.join(' ')
|
391
|
+
end
|
392
|
+
|
393
|
+
# @param [Hash] xcconfig_values_by_consumer_by_key
|
394
|
+
#
|
395
|
+
# @param [#to_s] attribute
|
396
|
+
# The name of the attribute being merged
|
397
|
+
#
|
398
|
+
# @return [Hash<String, String>]
|
399
|
+
#
|
400
|
+
def merged_xcconfigs(xcconfig_values_by_consumer_by_key, attribute)
|
401
|
+
xcconfig_values_by_consumer_by_key.each_with_object({}) do |(key, values_by_consumer), xcconfig|
|
402
|
+
uniq_values = values_by_consumer.values.uniq
|
403
|
+
values_are_bools = uniq_values.all? { |v| v =~ /\A(yes|no)\z/i }
|
404
|
+
if values_are_bools
|
405
|
+
# Boolean build settings
|
406
|
+
if uniq_values.count > 1
|
407
|
+
UI.warn "Can't merge #{attribute} for pod targets: " \
|
408
|
+
"#{values_by_consumer.keys.map(&:name)}. Boolean build " \
|
409
|
+
"setting #{key} has different values."
|
410
|
+
else
|
411
|
+
xcconfig[key] = uniq_values.first
|
412
|
+
end
|
413
|
+
elsif PLURAL_SETTINGS.include? key
|
414
|
+
# Plural build settings
|
415
|
+
xcconfig[key] = uniq_values.join(' ')
|
416
|
+
elsif uniq_values.count > 1
|
417
|
+
# Singular build settings
|
418
|
+
UI.warn "Can't merge #{attribute} for pod targets: " \
|
419
|
+
"#{values_by_consumer.keys.map(&:name)}. Singular build " \
|
420
|
+
"setting #{key} has different values."
|
421
|
+
else
|
422
|
+
xcconfig[key] = uniq_values.first
|
423
|
+
end
|
424
|
+
end
|
425
|
+
end
|
426
|
+
|
427
|
+
# Filters out pod targets whose `specs` are a subset of
|
428
|
+
# another target's.
|
429
|
+
#
|
430
|
+
# @param [Array<PodTarget>] pod_targets
|
431
|
+
#
|
432
|
+
# @return [Array<PodTarget>]
|
433
|
+
#
|
434
|
+
def select_maximal_pod_targets(pod_targets)
|
435
|
+
subset_targets = []
|
436
|
+
pod_targets.uniq.combination(2) do |a, b|
|
437
|
+
if (a.specs - b.specs).empty?
|
438
|
+
subset_targets << a
|
439
|
+
elsif (b.specs - a.specs).empty?
|
440
|
+
subset_targets << b
|
441
|
+
end
|
442
|
+
end
|
443
|
+
pod_targets - subset_targets
|
444
|
+
end
|
445
|
+
|
446
|
+
# A subclass that generates build settings for a {PodTarget}
|
447
|
+
class PodTargetSettings < BuildSettings
|
448
|
+
#-------------------------------------------------------------------------#
|
449
|
+
|
450
|
+
# @!group Public API
|
451
|
+
|
452
|
+
# @see BuildSettings.build_settings_names
|
453
|
+
def self.build_settings_names
|
454
|
+
@build_settings_names | BuildSettings.build_settings_names
|
455
|
+
end
|
456
|
+
|
457
|
+
# @return [Boolean]
|
458
|
+
# whether settings are being generated for a test bundle
|
459
|
+
#
|
460
|
+
attr_reader :test_xcconfig
|
461
|
+
alias test_xcconfig? test_xcconfig
|
462
|
+
|
463
|
+
# @return [Specification]
|
464
|
+
# The test specification these build settings are for or `nil`.
|
465
|
+
#
|
466
|
+
attr_reader :test_spec
|
467
|
+
|
468
|
+
# Initializes a new instance
|
469
|
+
#
|
470
|
+
# @param [PodTarget] target
|
471
|
+
# see {#target}
|
472
|
+
#
|
473
|
+
# @param [Specification] test_spec
|
474
|
+
# see {#test_spec}
|
475
|
+
#
|
476
|
+
def initialize(target, test_spec = nil)
|
477
|
+
super(target)
|
478
|
+
@test_spec = test_spec
|
479
|
+
@test_xcconfig = !test_spec.nil?
|
480
|
+
end
|
481
|
+
|
482
|
+
# @return [Xcodeproj::Xconfig]
|
483
|
+
define_build_settings_method :xcconfig, :memoized => true do
|
484
|
+
xcconfig = super()
|
485
|
+
xcconfig.merge(merged_pod_target_xcconfigs)
|
486
|
+
end
|
487
|
+
|
488
|
+
#-------------------------------------------------------------------------#
|
489
|
+
|
490
|
+
# @!group Paths
|
491
|
+
|
492
|
+
# @return [String]
|
493
|
+
define_build_settings_method :pods_root, :build_setting => true do
|
494
|
+
'${SRCROOT}'
|
495
|
+
end
|
496
|
+
|
497
|
+
# @return [String]
|
498
|
+
define_build_settings_method :pods_target_srcroot, :build_setting => true do
|
499
|
+
target.pod_target_srcroot
|
500
|
+
end
|
501
|
+
|
502
|
+
#-------------------------------------------------------------------------#
|
503
|
+
|
504
|
+
# @!group Frameworks
|
505
|
+
|
506
|
+
# @return [Array<String>]
|
507
|
+
define_build_settings_method :consumer_frameworks, :memoized => true do
|
508
|
+
spec_consumers.flat_map(&:frameworks)
|
509
|
+
end
|
510
|
+
|
511
|
+
# @return [Array<String>]
|
512
|
+
define_build_settings_method :frameworks, :memoized => true, :sorted => true, :uniqued => true do
|
513
|
+
return [] if (!target.requires_frameworks? || target.static_framework?) && !test_xcconfig?
|
514
|
+
|
515
|
+
frameworks = []
|
516
|
+
frameworks.concat consumer_frameworks
|
517
|
+
if test_xcconfig? || (target.should_build? && target.requires_frameworks? && !target.static_framework?)
|
518
|
+
frameworks.concat vendored_static_frameworks.map { |l| File.basename(l, '.framework') }
|
519
|
+
end
|
520
|
+
if test_xcconfig?
|
521
|
+
frameworks.concat vendored_dynamic_frameworks.map { |l| File.basename(l, '.framework') }
|
522
|
+
frameworks.concat dependent_targets.flat_map { |pt| pt.build_settings.frameworks_to_import }
|
523
|
+
end
|
524
|
+
frameworks
|
525
|
+
end
|
526
|
+
|
527
|
+
# @return [Array<String>]
|
528
|
+
define_build_settings_method :static_frameworks_to_import, :memoized => true do
|
529
|
+
static_frameworks_to_import = []
|
530
|
+
static_frameworks_to_import.concat vendored_static_frameworks.map { |f| File.basename(f, '.framework') } unless target.should_build? && target.requires_frameworks? && !target.static_framework?
|
531
|
+
static_frameworks_to_import << target.product_basename if target.should_build? && target.requires_frameworks? && target.static_framework?
|
532
|
+
static_frameworks_to_import
|
533
|
+
end
|
534
|
+
|
535
|
+
# @return [Array<String>]
|
536
|
+
define_build_settings_method :dynamic_frameworks_to_import, :memoized => true do
|
537
|
+
dynamic_frameworks_to_import = vendored_dynamic_frameworks.map { |f| File.basename(f, '.framework') }
|
538
|
+
dynamic_frameworks_to_import << target.product_basename if target.should_build? && target.requires_frameworks? && !target.static_framework?
|
539
|
+
dynamic_frameworks_to_import.concat consumer_frameworks
|
540
|
+
dynamic_frameworks_to_import
|
541
|
+
end
|
542
|
+
|
543
|
+
# @return [Array<String>]
|
544
|
+
define_build_settings_method :weak_frameworks, :memoized => true, :sorted => true, :uniqued => true do
|
545
|
+
return [] if (!target.requires_frameworks? || target.static_framework?) && !test_xcconfig?
|
546
|
+
|
547
|
+
weak_frameworks = spec_consumers.flat_map(&:weak_frameworks)
|
548
|
+
weak_frameworks.concat dependent_targets.flat_map { |pt| pt.build_settings.weak_frameworks_to_import }
|
549
|
+
weak_frameworks
|
550
|
+
end
|
551
|
+
|
552
|
+
# @return [Array<String>]
|
553
|
+
define_build_settings_method :frameworks_to_import, :memoized => true, :sorted => true, :uniqued => true do
|
554
|
+
static_frameworks_to_import + dynamic_frameworks_to_import
|
555
|
+
end
|
556
|
+
|
557
|
+
# @return [Array<String>]
|
558
|
+
define_build_settings_method :weak_frameworks_to_import, :memoized => true, :sorted => true, :uniqued => true do
|
559
|
+
spec_consumers.flat_map(&:weak_frameworks)
|
560
|
+
end
|
561
|
+
|
562
|
+
# @return [Array<String>]
|
563
|
+
define_build_settings_method :framework_search_paths, :build_setting => true, :memoized => true, :sorted => true, :uniqued => true do
|
564
|
+
paths = super().dup
|
565
|
+
paths.concat dependent_targets.flat_map { |t| t.build_settings.framework_search_paths_to_import }
|
566
|
+
paths.concat framework_search_paths_to_import
|
567
|
+
paths.delete(target.configuration_build_dir(CONFIGURATION_BUILD_DIR_VARIABLE)) unless test_xcconfig?
|
568
|
+
paths
|
569
|
+
end
|
570
|
+
|
571
|
+
# @return [String]
|
572
|
+
define_build_settings_method :framework_header_search_path, :memoized => true do
|
573
|
+
return unless target.requires_frameworks?
|
574
|
+
"#{target.build_product_path}/Headers"
|
575
|
+
end
|
576
|
+
|
577
|
+
# @return [Array<String>]
|
578
|
+
define_build_settings_method :vendored_framework_search_paths, :memoized => true do
|
579
|
+
file_accessors.flat_map(&:vendored_frameworks).map { |f| File.join '${PODS_ROOT}', f.dirname.relative_path_from(target.sandbox.root) }
|
580
|
+
end
|
581
|
+
|
582
|
+
# @return [Array<String>]
|
583
|
+
define_build_settings_method :framework_search_paths_to_import, :memoized => true do
|
584
|
+
paths = framework_search_paths_to_import_developer_frameworks(consumer_frameworks)
|
585
|
+
paths.concat vendored_framework_search_paths
|
586
|
+
return paths unless target.requires_frameworks? && target.should_build?
|
587
|
+
|
588
|
+
paths + [target.configuration_build_dir(CONFIGURATION_BUILD_DIR_VARIABLE)]
|
589
|
+
end
|
590
|
+
|
591
|
+
# @return [Array<String>]
|
592
|
+
define_build_settings_method :vendored_static_frameworks, :memoized => true do
|
593
|
+
file_accessors.flat_map(&:vendored_static_frameworks)
|
594
|
+
end
|
595
|
+
|
596
|
+
# @return [Array<String>]
|
597
|
+
define_build_settings_method :vendored_dynamic_frameworks, :memoized => true do
|
598
|
+
file_accessors.flat_map(&:vendored_dynamic_frameworks)
|
599
|
+
end
|
600
|
+
|
601
|
+
#-------------------------------------------------------------------------#
|
602
|
+
|
603
|
+
# @!group Libraries
|
604
|
+
|
605
|
+
# Converts array of library path references to just the names to use
|
606
|
+
# link each library, e.g. from '/path/to/libSomething.a' to 'Something'
|
607
|
+
#
|
608
|
+
# @param [Array<String>] libraries
|
609
|
+
#
|
610
|
+
# @return [Array<String>]
|
611
|
+
#
|
612
|
+
def linker_names_from_libraries(libraries)
|
613
|
+
libraries.map { |l| File.basename(l, l.extname).sub(/\Alib/, '') }
|
614
|
+
end
|
615
|
+
|
616
|
+
# @return [Array<String>]
|
617
|
+
define_build_settings_method :libraries, :memoized => true, :sorted => true, :uniqued => true do
|
618
|
+
return [] if (!target.requires_frameworks? || target.static_framework?) && !test_xcconfig?
|
619
|
+
|
620
|
+
libraries = []
|
621
|
+
if test_xcconfig? || target.requires_frameworks? && !target.static_framework?
|
622
|
+
libraries.concat linker_names_from_libraries(vendored_static_libraries)
|
623
|
+
libraries.concat libraries_to_import
|
624
|
+
end
|
625
|
+
if test_xcconfig?
|
626
|
+
libraries.concat dependent_targets.flat_map { |pt| pt.build_settings.dynamic_libraries_to_import }
|
627
|
+
libraries.concat dependent_targets.flat_map { |pt| pt.build_settings.static_libraries_to_import }
|
628
|
+
end
|
629
|
+
libraries
|
630
|
+
end
|
631
|
+
|
632
|
+
# @return [Array<String>]
|
633
|
+
define_build_settings_method :static_libraries_to_import, :memoized => true do
|
634
|
+
static_libraries_to_import = []
|
635
|
+
unless target.should_build? && target.requires_frameworks? && !target.static_framework?
|
636
|
+
static_libraries_to_import.concat linker_names_from_libraries(vendored_static_libraries)
|
637
|
+
end
|
638
|
+
static_libraries_to_import << target.product_basename if target.should_build? && !target.requires_frameworks?
|
639
|
+
static_libraries_to_import
|
640
|
+
end
|
641
|
+
|
642
|
+
# @return [Array<String>]
|
643
|
+
define_build_settings_method :dynamic_libraries_to_import, :memoized => true do
|
644
|
+
linker_names_from_libraries(vendored_dynamic_libraries) +
|
645
|
+
spec_consumers.flat_map(&:libraries)
|
646
|
+
end
|
647
|
+
|
648
|
+
# @return [Array<String>]
|
649
|
+
define_build_settings_method :libraries_to_import, :memoized => true, :sorted => true, :uniqued => true do
|
650
|
+
static_libraries_to_import + dynamic_libraries_to_import
|
651
|
+
end
|
652
|
+
|
653
|
+
# @return [Array<String>]
|
654
|
+
define_build_settings_method :library_search_paths, :build_setting => true, :memoized => true, :sorted => true, :uniqued => true do
|
655
|
+
return [] if (!target.requires_frameworks? || target.static_framework?) && !test_xcconfig?
|
656
|
+
|
657
|
+
vendored = library_search_paths_to_import.dup
|
658
|
+
vendored.concat dependent_targets.flat_map { |t| t.build_settings.vendored_dynamic_library_search_paths }
|
659
|
+
if test_xcconfig?
|
660
|
+
vendored.concat dependent_targets.flat_map { |t| t.build_settings.library_search_paths_to_import }
|
661
|
+
else
|
662
|
+
vendored.delete(target.configuration_build_dir(CONFIGURATION_BUILD_DIR_VARIABLE))
|
663
|
+
end
|
664
|
+
vendored
|
665
|
+
end
|
666
|
+
|
667
|
+
# @return [Array<String>]
|
668
|
+
define_build_settings_method :vendored_static_libraries, :memoized => true do
|
669
|
+
file_accessors.flat_map(&:vendored_static_libraries)
|
670
|
+
end
|
671
|
+
|
672
|
+
# @return [Array<String>]
|
673
|
+
define_build_settings_method :vendored_dynamic_libraries, :memoized => true do
|
674
|
+
file_accessors.flat_map(&:vendored_dynamic_libraries)
|
675
|
+
end
|
676
|
+
|
677
|
+
# @return [Array<String>]
|
678
|
+
define_build_settings_method :vendored_static_library_search_paths, :memoized => true do
|
679
|
+
vendored_static_libraries.map { |f| File.join '${PODS_ROOT}', f.dirname.relative_path_from(target.sandbox.root) }
|
680
|
+
end
|
681
|
+
|
682
|
+
# @return [Array<String>]
|
683
|
+
define_build_settings_method :vendored_dynamic_library_search_paths, :memoized => true do
|
684
|
+
vendored_dynamic_libraries.map { |f| File.join '${PODS_ROOT}', f.dirname.relative_path_from(target.sandbox.root) }
|
685
|
+
end
|
686
|
+
|
687
|
+
# @return [Array<String>]
|
688
|
+
define_build_settings_method :library_search_paths_to_import, :memoized => true do
|
689
|
+
vendored_library_search_paths = vendored_static_library_search_paths + vendored_dynamic_library_search_paths
|
690
|
+
return vendored_library_search_paths if target.requires_frameworks? || !target.should_build?
|
691
|
+
|
692
|
+
vendored_library_search_paths << target.configuration_build_dir(CONFIGURATION_BUILD_DIR_VARIABLE)
|
693
|
+
end
|
694
|
+
|
695
|
+
#-------------------------------------------------------------------------#
|
696
|
+
|
697
|
+
# @!group Clang
|
698
|
+
|
699
|
+
# @return [Array<String>]
|
700
|
+
define_build_settings_method :module_map_files, :memoized => true do
|
701
|
+
dependent_targets.map { |t| t.build_settings.module_map_file_to_import }.compact.sort
|
702
|
+
end
|
703
|
+
|
704
|
+
# @return [Array<String>]
|
705
|
+
define_build_settings_method :module_map_file_to_import, :memoized => true do
|
706
|
+
return unless target.should_build?
|
707
|
+
return if target.requires_frameworks?
|
708
|
+
return unless target.defines_module?
|
709
|
+
|
710
|
+
if target.uses_swift?
|
711
|
+
# for swift, we have a custom build phase that copies in the module map, appending the .Swift module
|
712
|
+
"${PODS_CONFIGURATION_BUILD_DIR}/#{target.label}/#{target.product_module_name}.modulemap"
|
713
|
+
else
|
714
|
+
"${PODS_ROOT}/#{target.module_map_path.relative_path_from(target.sandbox.root)}"
|
715
|
+
end
|
716
|
+
end
|
717
|
+
|
718
|
+
# @return [Array<String>]
|
719
|
+
define_build_settings_method :header_search_paths, :build_setting => true, :memoized => true, :sorted => true do
|
720
|
+
target.header_search_paths(:include_dependent_targets_for_test_spec => test_spec)
|
721
|
+
end
|
722
|
+
|
723
|
+
# @return [Array<String>]
|
724
|
+
define_build_settings_method :public_header_search_paths, :memoized => true, :sorted => true do
|
725
|
+
target.header_search_paths(:include_dependent_targets_for_test_spec => test_xcconfig?, :include_private_headers => false)
|
726
|
+
end
|
727
|
+
|
728
|
+
#-------------------------------------------------------------------------#
|
729
|
+
|
730
|
+
# @!group Swift
|
731
|
+
|
732
|
+
# @return [Array<String>]
|
733
|
+
define_build_settings_method :other_swift_flags, :build_setting => true, :memoized => true do
|
734
|
+
return unless target.uses_swift?
|
735
|
+
flags = super()
|
736
|
+
flags << '-suppress-warnings' if target.inhibit_warnings?
|
737
|
+
if !target.requires_frameworks? && target.defines_module? && !test_xcconfig?
|
738
|
+
flags.concat %w( -import-underlying-module -Xcc -fmodule-map-file=${SRCROOT}/${MODULEMAP_FILE} )
|
739
|
+
end
|
740
|
+
flags
|
741
|
+
end
|
742
|
+
|
743
|
+
# @return [Array<String>]
|
744
|
+
define_build_settings_method :swift_include_paths, :build_setting => true, :memoized => true, :sorted => true, :uniqued => true do
|
745
|
+
paths = dependent_targets.flat_map { |t| t.build_settings.swift_include_paths_to_import }
|
746
|
+
paths.concat swift_include_paths_to_import if test_xcconfig?
|
747
|
+
paths
|
748
|
+
end
|
749
|
+
|
750
|
+
# @return [Array<String>]
|
751
|
+
define_build_settings_method :swift_include_paths_to_import, :memoized => true do
|
752
|
+
return [] unless target.uses_swift? && !target.requires_frameworks?
|
753
|
+
|
754
|
+
[target.configuration_build_dir(CONFIGURATION_BUILD_DIR_VARIABLE)]
|
755
|
+
end
|
756
|
+
|
757
|
+
#-------------------------------------------------------------------------#
|
758
|
+
|
759
|
+
# @!group Linking
|
760
|
+
|
761
|
+
# @return [Boolean] whether the `-ObjC` linker flag is required.
|
762
|
+
#
|
763
|
+
# @note this is only true when generating build settings for a test bundle
|
764
|
+
#
|
765
|
+
def requires_objc_linker_flag?
|
766
|
+
test_xcconfig?
|
767
|
+
end
|
768
|
+
|
769
|
+
# @return [Boolean] whether the `-fobjc-arc` linker flag is required.
|
770
|
+
#
|
771
|
+
define_build_settings_method :requires_fobjc_arc?, :memoized => true do
|
772
|
+
target.podfile.set_arc_compatibility_flag? &&
|
773
|
+
file_accessors.any? { |fa| fa.spec_consumer.requires_arc? }
|
774
|
+
end
|
775
|
+
|
776
|
+
# @return [Array<String>]
|
777
|
+
define_build_settings_method :ld_runpath_search_paths, :build_setting => true, :memoized => true do
|
778
|
+
return unless test_xcconfig?
|
779
|
+
_ld_runpath_search_paths(:test_bundle => true)
|
780
|
+
end
|
781
|
+
|
782
|
+
#-------------------------------------------------------------------------#
|
783
|
+
|
784
|
+
# @!group Packaging
|
785
|
+
|
786
|
+
# @return [String]
|
787
|
+
define_build_settings_method :skip_install, :build_setting => true do
|
788
|
+
'YES'
|
789
|
+
end
|
790
|
+
|
791
|
+
# @return [String]
|
792
|
+
define_build_settings_method :product_bundle_identifier, :build_setting => true do
|
793
|
+
'org.cocoapods.${PRODUCT_NAME:rfc1034identifier}'
|
794
|
+
end
|
795
|
+
|
796
|
+
# @return [String]
|
797
|
+
define_build_settings_method :configuration_build_dir, :build_setting => true, :memoized => true do
|
798
|
+
return if test_xcconfig?
|
799
|
+
target.configuration_build_dir(CONFIGURATION_BUILD_DIR_VARIABLE)
|
800
|
+
end
|
801
|
+
|
802
|
+
#-------------------------------------------------------------------------#
|
803
|
+
|
804
|
+
# @!group Target Properties
|
805
|
+
|
806
|
+
# @return [Array<PodTarget>]
|
807
|
+
define_build_settings_method :dependent_targets, :memoized => true do
|
808
|
+
select_maximal_pod_targets(
|
809
|
+
if test_xcconfig?
|
810
|
+
target.dependent_targets_for_test_spec(test_spec)
|
811
|
+
else
|
812
|
+
target.recursive_dependent_targets
|
813
|
+
end,
|
814
|
+
)
|
815
|
+
end
|
816
|
+
|
817
|
+
# Returns the +pod_target_xcconfig+ for the pod target and its spec
|
818
|
+
# consumers grouped by keys
|
819
|
+
#
|
820
|
+
# @return [Hash{String,Hash{Target,String}]
|
821
|
+
#
|
822
|
+
def pod_target_xcconfig_values_by_consumer_by_key
|
823
|
+
spec_consumers.each_with_object({}) do |spec_consumer, hash|
|
824
|
+
spec_consumer.pod_target_xcconfig.each do |k, v|
|
825
|
+
(hash[k] ||= {})[spec_consumer] = v
|
826
|
+
end
|
827
|
+
end
|
828
|
+
end
|
829
|
+
|
830
|
+
# Merges the +pod_target_xcconfig+ for all pod targets into a
|
831
|
+
# single hash and warns on conflicting definitions.
|
832
|
+
#
|
833
|
+
# @return [Hash{String, String}]
|
834
|
+
#
|
835
|
+
define_build_settings_method :merged_pod_target_xcconfigs, :memoized => true do
|
836
|
+
merged_xcconfigs(pod_target_xcconfig_values_by_consumer_by_key, :pod_target_xcconfig)
|
837
|
+
end
|
838
|
+
|
839
|
+
# @return [Array<Sandbox::FileAccessor>]
|
840
|
+
define_build_settings_method :file_accessors, :memoized => true do
|
841
|
+
target.file_accessors.select { |fa| fa.spec.test_specification? == test_xcconfig? }
|
842
|
+
end
|
843
|
+
|
844
|
+
# @return [Array<Specification::Consumer>]
|
845
|
+
define_build_settings_method :spec_consumers, :memoized => true do
|
846
|
+
target.spec_consumers.select { |c| c.spec.test_specification? == test_xcconfig? }
|
847
|
+
end
|
848
|
+
|
849
|
+
#-------------------------------------------------------------------------#
|
850
|
+
end
|
851
|
+
|
852
|
+
# A subclass that generates build settings for a `PodTarget`
|
853
|
+
class AggregateTargetSettings < BuildSettings
|
854
|
+
#-------------------------------------------------------------------------#
|
855
|
+
|
856
|
+
# @!group Public API
|
857
|
+
|
858
|
+
# @see BuildSettings.build_settings_names
|
859
|
+
def self.build_settings_names
|
860
|
+
@build_settings_names | BuildSettings.build_settings_names
|
861
|
+
end
|
862
|
+
|
863
|
+
# @return [String]
|
864
|
+
# The build configuration these settings will be used for
|
865
|
+
attr_reader :configuration_name
|
866
|
+
|
867
|
+
# Intializes a new instance
|
868
|
+
#
|
869
|
+
# @param [AggregateTarget] target
|
870
|
+
# see {#target}
|
871
|
+
#
|
872
|
+
# @param [String] configuration_name
|
873
|
+
# see {#configuration_name}
|
874
|
+
#
|
875
|
+
def initialize(target, configuration_name)
|
876
|
+
super(target)
|
877
|
+
@configuration_name = configuration_name
|
878
|
+
end
|
879
|
+
|
880
|
+
# @return [Xcodeproj::Config] xcconfig
|
881
|
+
define_build_settings_method :xcconfig, :memoized => true do
|
882
|
+
xcconfig = super()
|
883
|
+
xcconfig.merge(merged_user_target_xcconfigs)
|
884
|
+
end
|
885
|
+
|
886
|
+
#-------------------------------------------------------------------------#
|
887
|
+
|
888
|
+
# @!group Paths
|
889
|
+
|
890
|
+
# @return [String]
|
891
|
+
define_build_settings_method :pods_podfile_dir_path, :build_setting => true, :memoized => true do
|
892
|
+
target.podfile_dir_relative_path
|
893
|
+
end
|
894
|
+
|
895
|
+
# @return [String]
|
896
|
+
define_build_settings_method :pods_root, :build_setting => true, :memoized => true do
|
897
|
+
target.relative_pods_root
|
898
|
+
end
|
899
|
+
|
900
|
+
#-------------------------------------------------------------------------#
|
901
|
+
|
902
|
+
# @!group Frameworks
|
903
|
+
|
904
|
+
# @return [Array<String>]
|
905
|
+
define_build_settings_method :frameworks, :memoized => true, :sorted => true, :uniqued => true, :from_pod_targets_to_link => true, :from_search_paths_aggregate_targets => :dynamic_frameworks_to_import do
|
906
|
+
[]
|
907
|
+
end
|
908
|
+
|
909
|
+
# @return [Array<String>]
|
910
|
+
define_build_settings_method :weak_frameworks, :memoized => true, :sorted => true, :uniqued => true, :from_pod_targets_to_link => true, :from_search_paths_aggregate_targets => :weak_frameworks do
|
911
|
+
[]
|
912
|
+
end
|
913
|
+
|
914
|
+
# @return [Array<String>]
|
915
|
+
define_build_settings_method :framework_search_paths, :build_setting => true, :memoized => true, :sorted => true, :uniqued => true, :from_pod_targets_to_link => true, :from_search_paths_aggregate_targets => :framework_search_paths_to_import do
|
916
|
+
[]
|
917
|
+
end
|
918
|
+
|
919
|
+
#-------------------------------------------------------------------------#
|
920
|
+
|
921
|
+
# @!group Libraries
|
922
|
+
|
923
|
+
# @return [Array<String>]
|
924
|
+
define_build_settings_method :libraries, :memoized => true, :sorted => true, :uniqued => true, :from_pod_targets_to_link => true, :from_search_paths_aggregate_targets => :dynamic_libraries_to_import do
|
925
|
+
[]
|
926
|
+
end
|
927
|
+
|
928
|
+
# @return [Array<String>]
|
929
|
+
define_build_settings_method :library_search_paths, :build_setting => true, :memoized => true, :sorted => true, :uniqued => true, :from_pod_targets_to_link => true, :from_search_paths_aggregate_targets => :vendored_dynamic_library_search_paths do
|
930
|
+
[]
|
931
|
+
end
|
932
|
+
|
933
|
+
#-------------------------------------------------------------------------#
|
934
|
+
|
935
|
+
# @!group Clang
|
936
|
+
|
937
|
+
# @return [Array<String>]
|
938
|
+
define_build_settings_method :header_search_paths, :build_setting => true, :memoized => true, :sorted => true, :uniqued => true do
|
939
|
+
paths = []
|
940
|
+
|
941
|
+
if !target.requires_frameworks? || !pod_targets.all?(&:should_build?)
|
942
|
+
paths.concat target.sandbox.public_headers.search_paths(target.platform)
|
943
|
+
end
|
944
|
+
|
945
|
+
# Make frameworks headers discoverable with any syntax (quotes,
|
946
|
+
# brackets, @import, etc.)
|
947
|
+
paths.concat pod_targets.
|
948
|
+
select { |pt| pt.requires_frameworks? && pt.should_build? }.
|
949
|
+
map { |pt| pt.build_settings.framework_header_search_path }
|
950
|
+
|
951
|
+
paths.concat target.search_paths_aggregate_targets.flat_map { |at| at.build_settings(configuration_name).header_search_paths }
|
952
|
+
|
953
|
+
paths
|
954
|
+
end
|
955
|
+
|
956
|
+
# @return [Array<String>]
|
957
|
+
define_build_settings_method :other_cflags, :build_setting => true, :memoized => true do
|
958
|
+
flags = super()
|
959
|
+
|
960
|
+
pod_targets_inhibiting_warnings = pod_targets.select(&:inhibit_warnings?)
|
961
|
+
|
962
|
+
silenced_headers = []
|
963
|
+
silenced_frameworks = []
|
964
|
+
pod_targets_inhibiting_warnings.each do |pt|
|
965
|
+
if pt.requires_frameworks? && pt.should_build?
|
966
|
+
silenced_headers.append pt.build_settings.framework_header_search_path
|
967
|
+
else
|
968
|
+
silenced_headers.concat pt.build_settings.public_header_search_paths
|
969
|
+
end
|
970
|
+
silenced_frameworks.concat pt.build_settings.framework_search_paths_to_import
|
971
|
+
end
|
972
|
+
|
973
|
+
flags += silenced_headers.uniq.flat_map { |p| ['-isystem', p] }
|
974
|
+
flags += silenced_frameworks.uniq.flat_map { |p| ['-iframework', p] }
|
975
|
+
|
976
|
+
flags
|
977
|
+
end
|
978
|
+
|
979
|
+
# @return [Array<String>]
|
980
|
+
define_build_settings_method :module_map_files, :memoized => true, :sorted => true, :uniqued => true, :compacted => true, :from_search_paths_aggregate_targets => :module_map_file_to_import do
|
981
|
+
pod_targets.map { |t| t.build_settings.module_map_file_to_import }
|
982
|
+
end
|
983
|
+
|
984
|
+
#-------------------------------------------------------------------------#
|
985
|
+
|
986
|
+
# @!group Swift
|
987
|
+
|
988
|
+
# @see BuildSettings#other_swift_flags_without_swift?
|
989
|
+
def other_swift_flags_without_swift?
|
990
|
+
module_map_files.any?
|
991
|
+
end
|
992
|
+
|
993
|
+
# @return [Array<String>]
|
994
|
+
define_build_settings_method :swift_include_paths, :build_setting => true, :memoized => true, :sorted => true, :uniqued => true, :from_pod_targets_to_link => true, :from_search_paths_aggregate_targets => :swift_include_paths_to_import do
|
995
|
+
[]
|
996
|
+
end
|
997
|
+
|
998
|
+
# @return [String]
|
999
|
+
define_build_settings_method :always_embed_swift_standard_libraries, :build_setting => true, :memoized => true do
|
1000
|
+
return unless must_embed_swift?
|
1001
|
+
return if target_swift_version < EMBED_STANDARD_LIBRARIES_MINIMUM_VERSION
|
1002
|
+
|
1003
|
+
'YES'
|
1004
|
+
end
|
1005
|
+
|
1006
|
+
# @return [String]
|
1007
|
+
define_build_settings_method :embedded_content_contains_swift, :build_setting => true, :memoized => true do
|
1008
|
+
return unless must_embed_swift?
|
1009
|
+
return if target_swift_version >= EMBED_STANDARD_LIBRARIES_MINIMUM_VERSION
|
1010
|
+
|
1011
|
+
'YES'
|
1012
|
+
end
|
1013
|
+
|
1014
|
+
# @return [Boolean]
|
1015
|
+
define_build_settings_method :must_embed_swift?, :memoized => true do
|
1016
|
+
!target.requires_host_target? && pod_targets.any?(&:uses_swift?)
|
1017
|
+
end
|
1018
|
+
|
1019
|
+
#-------------------------------------------------------------------------#
|
1020
|
+
|
1021
|
+
# @!group Linking
|
1022
|
+
|
1023
|
+
# @return [Array<String>]
|
1024
|
+
define_build_settings_method :ld_runpath_search_paths, :build_setting => true, :memoized => true, :uniqued => true do
|
1025
|
+
return unless target.requires_frameworks? || any_vendored_dynamic_artifacts?
|
1026
|
+
symbol_type = target.user_targets.map(&:symbol_type).uniq.first
|
1027
|
+
test_bundle = symbol_type == :octest_bundle || symbol_type == :unit_test_bundle || symbol_type == :ui_test_bundle
|
1028
|
+
_ld_runpath_search_paths(:requires_host_target => target.requires_host_target?, :test_bundle => test_bundle)
|
1029
|
+
end
|
1030
|
+
|
1031
|
+
# @return [Boolean]
|
1032
|
+
define_build_settings_method :any_vendored_dynamic_artifacts?, :memoized => true do
|
1033
|
+
pod_targets.any? do |pt|
|
1034
|
+
pt.file_accessors.any? do |fa|
|
1035
|
+
fa.vendored_dynamic_artifacts.any?
|
1036
|
+
end
|
1037
|
+
end
|
1038
|
+
end
|
1039
|
+
|
1040
|
+
# @return [Boolean]
|
1041
|
+
define_build_settings_method :requires_objc_linker_flag?, :memoized => true do
|
1042
|
+
!target.requires_frameworks? ||
|
1043
|
+
pod_targets.any?(&:static_framework?) ||
|
1044
|
+
pod_targets.flat_map(&:file_accessors).any? { |fa| !fa.vendored_static_artifacts.empty? }
|
1045
|
+
end
|
1046
|
+
|
1047
|
+
# @return [Boolean]
|
1048
|
+
define_build_settings_method :requires_fobjc_arc?, :memoized => true do
|
1049
|
+
target.podfile.set_arc_compatibility_flag? &&
|
1050
|
+
target.spec_consumers.any?(&:requires_arc?)
|
1051
|
+
end
|
1052
|
+
|
1053
|
+
#-------------------------------------------------------------------------#
|
1054
|
+
|
1055
|
+
# @!group Target Properties
|
1056
|
+
|
1057
|
+
# @return [Version] the SWIFT_VERSION of the target being integrated
|
1058
|
+
#
|
1059
|
+
define_build_settings_method :target_swift_version, :memoized => true, :frozen => false do
|
1060
|
+
swift_version = target.target_definition.swift_version
|
1061
|
+
swift_version = nil if swift_version.blank?
|
1062
|
+
Version.new(swift_version)
|
1063
|
+
end
|
1064
|
+
|
1065
|
+
EMBED_STANDARD_LIBRARIES_MINIMUM_VERSION = Version.new('2.3')
|
1066
|
+
private_constant :EMBED_STANDARD_LIBRARIES_MINIMUM_VERSION
|
1067
|
+
|
1068
|
+
# Returns the {PodTarget}s which are active for the current
|
1069
|
+
# configuration name.
|
1070
|
+
#
|
1071
|
+
# @return [Array<PodTarget>]
|
1072
|
+
#
|
1073
|
+
define_build_settings_method :pod_targets, :memoized => true do
|
1074
|
+
target.pod_targets_for_build_configuration(configuration_name)
|
1075
|
+
end
|
1076
|
+
|
1077
|
+
# @return [Array<PodTarget>]
|
1078
|
+
define_build_settings_method :pod_targets_to_link, :memoized => true do
|
1079
|
+
pod_targets -
|
1080
|
+
target.search_paths_aggregate_targets.flat_map { |at| at.build_settings(configuration_name).pod_targets_to_link }
|
1081
|
+
end
|
1082
|
+
|
1083
|
+
# @return [Array<PodTarget>]
|
1084
|
+
define_build_settings_method :search_paths_aggregate_target_pod_target_build_settings, :memoized => true, :uniqued => true do
|
1085
|
+
pod_targets = target.search_paths_aggregate_targets.flat_map { |at| at.build_settings(configuration_name).pod_targets }
|
1086
|
+
pod_targets = select_maximal_pod_targets(pod_targets)
|
1087
|
+
pod_targets.flat_map(&:build_settings)
|
1088
|
+
end
|
1089
|
+
|
1090
|
+
# Returns the +user_target_xcconfig+ for all pod targets and their spec
|
1091
|
+
# consumers grouped by keys
|
1092
|
+
#
|
1093
|
+
# @return [Hash{String,Hash{Target,String}]
|
1094
|
+
#
|
1095
|
+
def user_target_xcconfig_values_by_consumer_by_key
|
1096
|
+
targets = (pod_targets + target.search_paths_aggregate_targets.flat_map(&:pod_targets)).uniq
|
1097
|
+
targets.each_with_object({}) do |target, hash|
|
1098
|
+
target.spec_consumers.each do |spec_consumer|
|
1099
|
+
spec_consumer.user_target_xcconfig.each do |k, v|
|
1100
|
+
# TODO: Need to decide how we are going to ensure settings like these
|
1101
|
+
# are always excluded from the user's project.
|
1102
|
+
#
|
1103
|
+
# See https://github.com/CocoaPods/CocoaPods/issues/1216
|
1104
|
+
next if k == 'USE_HEADERMAP'
|
1105
|
+
(hash[k] ||= {})[spec_consumer] = v
|
1106
|
+
end
|
1107
|
+
end
|
1108
|
+
end
|
1109
|
+
end
|
1110
|
+
|
1111
|
+
# Merges the +user_target_xcconfig+ for all pod targets into a
|
1112
|
+
# single hash and warns on conflicting definitions.
|
1113
|
+
#
|
1114
|
+
# @return [Hash{String, String}]
|
1115
|
+
#
|
1116
|
+
define_build_settings_method :merged_user_target_xcconfigs, :memoized => true do
|
1117
|
+
merged_xcconfigs(user_target_xcconfig_values_by_consumer_by_key, :user_target_xcconfig)
|
1118
|
+
end
|
1119
|
+
|
1120
|
+
#-------------------------------------------------------------------------#
|
1121
|
+
end
|
1122
|
+
end
|
1123
|
+
end
|
1124
|
+
end
|