forked from CocoaPods/CocoaPods
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pod_target_settings_spec.rb
480 lines (417 loc) · 28.4 KB
/
pod_target_settings_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
require File.expand_path('../../../../spec_helper', __FILE__)
module Pod
class Target
class BuildSettings
describe PodTargetSettings do
describe 'in general' do
before do
@monkey_spec = fixture_spec('monkey/monkey.podspec')
@monkey_pod_target = fixture_pod_target(@monkey_spec)
vspec = stub(:library_specification? => true, :spec_type => :library)
consumer = stub(
"Spec Consumer (#{vspec} iOS)",
:spec => vspec,
:pod_target_xcconfig => {},
:libraries => ['xml2'],
:frameworks => [],
:weak_frameworks => [],
:platform_name => :ios,
)
file_accessor = stub(
'File Accessor',
:spec => vspec,
:spec_consumer => consumer,
:vendored_static_frameworks => [config.sandbox.root + 'AAA/StaticFramework.framework'],
:vendored_static_libraries => [config.sandbox.root + 'BBB/StaticLibrary.a'],
:vendored_dynamic_frameworks => [config.sandbox.root + 'CCC/VendoredFramework.framework'],
:vendored_dynamic_libraries => [config.sandbox.root + 'DDD/VendoredDyld.dyld'],
:vendored_xcframeworks => [],
)
file_accessor.stubs(:vendored_libraries => file_accessor.vendored_static_libraries + file_accessor.vendored_dynamic_libraries,
:vendored_frameworks => file_accessor.vendored_static_frameworks + file_accessor.vendored_dynamic_frameworks)
vendored_dep_target = stub(
'Vendored Dependent Target',
:name => 'BananaLib',
:pod_name => 'BananaLib',
:sandbox => config.sandbox,
:should_build? => false,
:build_as_framework? => true,
:dependent_targets => [],
:_add_recursive_dependent_targets => [],
:recursive_dependent_targets => [],
:file_accessors => [file_accessor],
:spec_consumers => [consumer],
:uses_modular_headers? => false,
:uses_swift? => false,
:specs => [vspec],
)
vendored_dep_target.stubs(:build_settings => { :debug => PodTargetSettings.new(vendored_dep_target, nil, :configuration => :debug) })
@spec = fixture_spec('banana-lib/BananaLib.podspec')
@pod_target = fixture_pod_target(@spec, BuildType.dynamic_framework)
@pod_target.dependent_targets = [@monkey_pod_target, vendored_dep_target]
@consumer = @pod_target.spec_consumers.first
@podfile = @pod_target.podfile
@generator = PodTargetSettings.new(@pod_target, nil, :configuration => :debug)
@spec.pod_target_xcconfig = { 'OTHER_LDFLAGS' => '-no_compact_unwind' }
@spec.user_target_xcconfig = { 'CLANG_CXX_LANGUAGE_STANDARD' => 'c++11' }
@spec.frameworks = ['QuartzCore']
@spec.weak_frameworks = ['iAd']
@spec.libraries = ['xml2']
file_accessors = [Sandbox::FileAccessor.new(fixture('banana-lib'), @consumer)]
@pod_target.stubs(:file_accessors).returns(file_accessors)
@xcconfig = @generator.dup.generate
end
it 'generates the xcconfig' do
@xcconfig.class.should == Xcodeproj::Config
end
it 'includes only the pod_target_xcconfig of the specifications' do
@xcconfig.to_hash['CLANG_CXX_LANGUAGE_STANDARD'].should.be.nil
@xcconfig.to_hash['OTHER_LDFLAGS'].should.include('-no_compact_unwind')
end
it 'does include the system libraries for the specifications' do
@xcconfig.to_hash['OTHER_LDFLAGS'].should.include('-l"xml2"')
end
it 'does include the system frameworks of the specifications' do
@xcconfig.to_hash['OTHER_LDFLAGS'].should.include('-framework "QuartzCore"')
end
it 'does include the system weak frameworks of the specifications' do
@xcconfig.to_hash['OTHER_LDFLAGS'].should.include('-weak_framework "iAd"')
end
it 'does include the vendored dynamic frameworks for dependency pods of the specification' do
@xcconfig.to_hash['OTHER_LDFLAGS'].should.include('-framework "dynamic-monkey"')
end
it 'does not include vendored static frameworks for dependency pods of the specification' do
@xcconfig.to_hash['OTHER_LDFLAGS'].should.not.include('-l"monkey.a"')
end
it 'does not configure the project to load all members that implement Objective-c classes or categories from the static library' do
@xcconfig.to_hash['OTHER_LDFLAGS'].should.not.include '-ObjC'
end
it 'does not add the -fobjc-arc to OTHER_LDFLAGS by default as Xcode 4.3.2 does not support it' do
@consumer.stubs(:requires_arc?).returns(true)
@xcconfig.to_hash['OTHER_LDFLAGS'].should.not.include('-fobjc-arc')
end
it 'adds the -fobjc-arc to OTHER_LDFLAGS if any pods require arc and the podfile explicitly requires it' do
@podfile.stubs(:set_arc_compatibility_flag?).returns(true)
@consumer.stubs(:requires_arc?).returns(true)
@xcconfig = @generator.generate
@xcconfig.to_hash['OTHER_LDFLAGS'].split(' ').should.include('-fobjc-arc')
end
it 'sets the framework search paths' do
@xcconfig.to_hash['FRAMEWORK_SEARCH_PATHS'].should.include('spec/fixtures/banana-lib')
@xcconfig.to_hash['FRAMEWORK_SEARCH_PATHS'].should.include('spec/fixtures/monkey')
@xcconfig.to_hash['FRAMEWORK_SEARCH_PATHS'].should.include('${PODS_ROOT}/AAA')
@xcconfig.to_hash['FRAMEWORK_SEARCH_PATHS'].should.not.include('${PODS_ROOT}/BBB')
@xcconfig.to_hash['FRAMEWORK_SEARCH_PATHS'].should.include('${PODS_ROOT}/CCC')
@xcconfig.to_hash['FRAMEWORK_SEARCH_PATHS'].should.not.include('${PODS_ROOT}/DDD')
end
it 'vendored frameworks should be added to frameworks paths if use_frameworks! isnt set' do
@pod_target.stubs(:build_type).returns(BuildType.static_library)
@xcconfig = @generator.generate
@xcconfig.to_hash['FRAMEWORK_SEARCH_PATHS'].should.include('spec/fixtures/monkey')
@xcconfig.to_hash['FRAMEWORK_SEARCH_PATHS'].should.include('${PODS_ROOT}/AAA')
@xcconfig.to_hash['FRAMEWORK_SEARCH_PATHS'].should.include('${PODS_ROOT}/CCC')
end
it 'sets the PODS_ROOT build variable' do
@xcconfig.to_hash['PODS_ROOT'].should.not.nil?
end
it 'sets the PODS_TARGET_SRCROOT build variable for non local pod' do
@xcconfig.to_hash['PODS_TARGET_SRCROOT'].should == '${PODS_ROOT}/BananaLib'
end
it 'sets the PODS_TARGET_SRCROOT build variable for local pod' do
@pod_target.sandbox.store_local_path(@pod_target.pod_name, @spec.defined_in_file)
@xcconfig = @generator.generate
@xcconfig.to_hash['PODS_TARGET_SRCROOT'].should == '${PODS_ROOT}/../../spec/fixtures/banana-lib'
end
it 'does not add root public or private header search paths to the xcconfig' do
@xcconfig.to_hash['HEADER_SEARCH_PATHS'].should.be.nil
end
it 'adds the COCOAPODS macro definition' do
expected = '$(inherited) COCOAPODS=1'
@xcconfig.to_hash['GCC_PREPROCESSOR_DEFINITIONS'].should == expected
end
it 'sets the relative path of the pods root for spec libraries to ${SRCROOT}' do
@xcconfig.to_hash['PODS_ROOT'].should == '${SRCROOT}'
end
it 'sets the PODS_BUILD_DIR build variable' do
@xcconfig.to_hash['PODS_BUILD_DIR'].should == '${BUILD_DIR}'
end
it 'sets the PODS_CONFIGURATION_BUILD_DIR build variable' do
@xcconfig.to_hash['PODS_CONFIGURATION_BUILD_DIR'].should == '${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)'
end
it 'sets the CONFIGURATION_BUILD_DIR build variable' do
@xcconfig.to_hash['CONFIGURATION_BUILD_DIR'].should.be == '${PODS_CONFIGURATION_BUILD_DIR}/BananaLib'
end
it 'will be skipped when installing' do
@xcconfig.to_hash['SKIP_INSTALL'].should == 'YES'
end
it 'sets PRODUCT_BUNDLE_IDENTIFIER' do
@xcconfig.to_hash['PRODUCT_BUNDLE_IDENTIFIER'].should == 'org.cocoapods.${PRODUCT_NAME:rfc1034identifier}'
end
it 'does not have a module map to import if it is not built' do
@pod_target.stubs(:should_build? => false, :build_as_framework? => false, :defines_module? => true)
@generator.generate
@generator.module_map_file_to_import.should.be.nil
end
it 'includes xctunwrap fix for a pod target with deployment target < 12.2 and links XCTest' do
@spec.frameworks = ['XCTest']
@pod_target.stubs(:platform).returns(Platform.new(:ios, '12.1'))
generator = PodTargetSettings.new(@pod_target, nil, :configuration => :debug)
hash = generator.generate.to_hash
hash['SYSTEM_FRAMEWORK_SEARCH_PATHS'].should.include '"$(PLATFORM_DIR)/Developer/Library/Frameworks"'
hash['LIBRARY_SEARCH_PATHS'].should.include '"$(PLATFORM_DIR)/Developer/usr/lib"'
hash['SWIFT_INCLUDE_PATHS'].should.include '"$(PLATFORM_DIR)/Developer/usr/lib"'
end
it 'includes xctunwrap fix for a pod target with deployment target < 12.2 and weakly links XCTest' do
@spec.weak_frameworks = ['XCTest']
@pod_target.stubs(:platform).returns(Platform.new(:ios, '12.1'))
generator = PodTargetSettings.new(@pod_target, nil, :configuration => :debug)
hash = generator.generate.to_hash
hash['SYSTEM_FRAMEWORK_SEARCH_PATHS'].should.include '"$(PLATFORM_DIR)/Developer/Library/Frameworks"'
hash['LIBRARY_SEARCH_PATHS'].should.include '"$(PLATFORM_DIR)/Developer/usr/lib"'
hash['SWIFT_INCLUDE_PATHS'].should.include '"$(PLATFORM_DIR)/Developer/usr/lib"'
end
it 'does not include xctunwrap fix for a pod target with higher than 12.1 deployment target' do
@spec.frameworks = ['XCTest']
@pod_target.stubs(:platform).returns(Platform.new(:ios, '12.2'))
generator = PodTargetSettings.new(@pod_target, nil, :configuration => :debug)
hash = generator.generate.to_hash
hash['SYSTEM_FRAMEWORK_SEARCH_PATHS'].should.be.nil
hash['LIBRARY_SEARCH_PATHS'].should.not.include '"$(PLATFORM_DIR)/Developer/usr/lib"'
hash['SWIFT_INCLUDE_PATHS'].should.not.include '"$(PLATFORM_DIR)/Developer/usr/lib"'
end
it 'saves the xcconfig' do
path = temporary_directory + 'sample.xcconfig'
@generator.save_as(path)
generated = Xcodeproj::Config.new(path)
generated.class.should == Xcodeproj::Config
end
it 'does propagate framework or libraries' do
spec = stub('spec', :library_specification? => true, :spec_type => :library)
consumer = stub('consumer',
:libraries => ['xml2'],
:frameworks => ['XCTest'],
:weak_frameworks => [],
:spec => spec,
)
file_accessor = stub('file_accessor',
:spec => spec,
:spec_consumer => consumer,
:vendored_static_frameworks => [config.sandbox.root + 'StaticFramework.framework'],
:vendored_static_libraries => [config.sandbox.root + 'StaticLibrary.a'],
:vendored_dynamic_frameworks => [config.sandbox.root + 'VendoredFramework.framework'],
:vendored_dynamic_libraries => [config.sandbox.root + 'VendoredDyld.dyld'],
:vendored_xcframeworks => [],
)
pod_target = stub('pod_target',
:file_accessors => [file_accessor],
:spec_consumers => [consumer],
:build_as_framework? => true,
:build_as_static_framework? => true,
:build_as_dynamic_library? => false,
:build_as_dynamic_framework? => false,
:dependent_targets => [],
:recursive_dependent_targets => [],
:sandbox => config.sandbox,
:should_build? => true,
)
pod_target.stubs(:build_settings => { :debug => PodTargetSettings.new(pod_target, nil, :configuration => :debug) })
@generator.spec_consumers.each { |sc| sc.stubs(:frameworks => []) }
@generator.stubs(:dependent_targets => [pod_target])
@generator.other_ldflags.should.
be == %w(-l"BananaStaticLib" -l"xml2" -framework "BananaFramework" -framework "VendoredFramework" -framework "dynamic-monkey" -weak_framework "iAd")
end
end
describe 'test xcconfig generation' do
before do
@monkey_spec = fixture_spec('monkey/monkey.podspec')
@monkey_pod_target = fixture_pod_target(@monkey_spec)
@banana_spec = fixture_spec('banana-lib/BananaLib.podspec')
@banana_pod_target = fixture_pod_target(@banana_spec)
@matryoshka_spec = fixture_spec('matryoshka/matryoshka.podspec')
@matryoshka_pod_target = fixture_pod_target_with_specs([@matryoshka_spec, *@matryoshka_spec.subspecs])
@coconut_spec = fixture_spec('coconut-lib/CoconutLib.podspec')
@coconut_test_spec = @coconut_spec.test_specs.first
@coconut_pod_target = fixture_pod_target_with_specs([@coconut_spec, @coconut_test_spec])
end
it 'does not merge pod target xcconfig of test specifications for a non test xcconfig' do
@coconut_spec.pod_target_xcconfig = { 'GCC_PREPROCESSOR_DEFINITIONS' => 'NON_TEST_FLAG=1', 'PODS_ROOT' => 'OVERRIDDEN', 'GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED' => 'YES', 'GCC_TREAT_WARNINGS_AS_ERRORS' => 'YES' }
@coconut_test_spec.pod_target_xcconfig = { 'GCC_PREPROCESSOR_DEFINITIONS' => 'TEST_ONLY=1', 'PODS_ROOT' => 'OVERRIDDEN2', 'GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED' => 'YES', 'GCC_TREAT_WARNINGS_AS_ERRORS' => 'NO' }
generator = PodTargetSettings.new(@coconut_pod_target, nil, :configuration => :debug)
xcconfig = generator.generate
xcconfig.to_hash['GCC_PREPROCESSOR_DEFINITIONS'].should == '$(inherited) COCOAPODS=1 NON_TEST_FLAG=1'
xcconfig.to_hash['PODS_ROOT'].should == 'OVERRIDDEN'
xcconfig.to_hash['GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED'].should == 'YES'
xcconfig.to_hash['GCC_TREAT_WARNINGS_AS_ERRORS'].should == 'YES'
generator = PodTargetSettings.new(@coconut_pod_target, @coconut_test_spec, :configuration => :debug)
xcconfig = generator.generate
xcconfig.to_hash['GCC_PREPROCESSOR_DEFINITIONS'].should == '$(inherited) COCOAPODS=1 NON_TEST_FLAG=1 TEST_ONLY=1'
xcconfig.to_hash['PODS_ROOT'].should == 'OVERRIDDEN2'
xcconfig.to_hash['GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED'].should == 'YES'
xcconfig.to_hash['GCC_TREAT_WARNINGS_AS_ERRORS'].should == 'NO'
UI.warnings.should.be.empty
end
it 'merges pod target xcconfig settings from subspecs' do
@matryoshka_spec.subspecs[0].pod_target_xcconfig = { 'GCC_PREPROCESSOR_DEFINITIONS' => 'FIRST_SUBSPEC_FLAG=1', 'PODS_ROOT' => 'OVERRIDDEN' }
@matryoshka_spec.subspecs[1].pod_target_xcconfig = { 'GCC_PREPROCESSOR_DEFINITIONS' => 'SECOND_SUBSPEC_FLAG=1' }
generator = PodTargetSettings.new(@matryoshka_pod_target, nil, :configuration => :debug)
xcconfig = generator.generate
xcconfig.to_hash['GCC_PREPROCESSOR_DEFINITIONS'].should == '$(inherited) COCOAPODS=1 FIRST_SUBSPEC_FLAG=1 SECOND_SUBSPEC_FLAG=1'
xcconfig.to_hash['PODS_ROOT'].should == 'OVERRIDDEN'
end
it 'merges the pod target xcconfig of non test specifications for test xcconfigs' do
@coconut_spec.pod_target_xcconfig = { 'GCC_PREPROCESSOR_DEFINITIONS' => 'NON_TEST_FLAG=1' }
@coconut_test_spec.pod_target_xcconfig = { 'GCC_PREPROCESSOR_DEFINITIONS' => 'TEST_ONLY=1' }
generator = PodTargetSettings.new(@coconut_pod_target, @coconut_test_spec, :configuration => :debug)
xcconfig = generator.generate
xcconfig.to_hash['GCC_PREPROCESSOR_DEFINITIONS'].should == '$(inherited) COCOAPODS=1 NON_TEST_FLAG=1 TEST_ONLY=1'
end
it 'includes correct other ld flags' do
generator = PodTargetSettings.new(@coconut_pod_target, @coconut_test_spec, :configuration => :debug)
xcconfig = generator.generate
xcconfig.to_hash['OTHER_LDFLAGS'].should == '$(inherited) -ObjC -l"CoconutLib"'
end
it 'includes correct other ld flags when requires frameworks' do
@coconut_pod_target.stubs(:build_type => BuildType.dynamic_framework)
generator = PodTargetSettings.new(@coconut_pod_target, @coconut_test_spec, :configuration => :debug)
xcconfig = generator.generate
xcconfig.to_hash['OTHER_LDFLAGS'].should == '$(inherited) -ObjC -framework "CoconutLib"'
end
it 'includes other ld flags for transitive dependent targets' do
@coconut_pod_target.dependent_targets = [@monkey_pod_target]
generator = PodTargetSettings.new(@coconut_pod_target, @coconut_test_spec, :configuration => :debug)
xcconfig = generator.generate
xcconfig.to_hash['OTHER_LDFLAGS'].should == '$(inherited) -ObjC -l"CoconutLib" -l"monkey" -framework "dynamic-monkey"'
end
it 'includes other ld flags for test dependent targets' do
@coconut_pod_target.test_dependent_targets_by_spec_name = { @coconut_test_spec.name => [@monkey_pod_target] }
generator = PodTargetSettings.new(@coconut_pod_target, @coconut_test_spec, :configuration => :debug)
xcconfig = generator.generate
xcconfig.to_hash['OTHER_LDFLAGS'].should == '$(inherited) -ObjC -l"CoconutLib" -l"monkey" -framework "dynamic-monkey"'
end
it 'adds settings for test dependent targets' do
@coconut_pod_target.test_dependent_targets_by_spec_name = { @coconut_test_spec.name => [@banana_pod_target] }
generator = PodTargetSettings.new(@coconut_pod_target, @coconut_test_spec, :configuration => :debug)
xcconfig = generator.generate
xcconfig.to_hash['FRAMEWORK_SEARCH_PATHS'].should == '$(inherited) "${PODS_ROOT}/../../spec/fixtures/banana-lib"'
xcconfig.to_hash['LIBRARY_SEARCH_PATHS'].should == '$(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/BananaLib" "${PODS_CONFIGURATION_BUILD_DIR}/CoconutLib" "${PODS_ROOT}/../../spec/fixtures/banana-lib"'
end
it 'adds settings for test dependent targets excluding the parents targets' do
@coconut_pod_target.dependent_targets = [@banana_pod_target]
@coconut_pod_target.test_dependent_targets_by_spec_name = { @coconut_test_spec.name => [@banana_pod_target] }
generator = PodTargetSettings.new(@coconut_pod_target, @coconut_test_spec, :configuration => :debug)
xcconfig = generator.generate
xcconfig.to_hash['FRAMEWORK_SEARCH_PATHS'].should == '$(inherited) "${PODS_ROOT}/../../spec/fixtures/banana-lib"'
xcconfig.to_hash['LIBRARY_SEARCH_PATHS'].should == '$(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/BananaLib" "${PODS_CONFIGURATION_BUILD_DIR}/CoconutLib" "${PODS_ROOT}/../../spec/fixtures/banana-lib"'
end
it 'adds the developer frameworks dir when XCTest is used but not linked' do
@banana_pod_target.spec_consumers.each { |sc| sc.stubs(:frameworks => %w(XCTest), :vendored_frameworks => []) }
@coconut_pod_target.dependent_targets = [@banana_pod_target]
generator = PodTargetSettings.new(@coconut_pod_target, nil, :configuration => :debug)
xcconfig = generator.generate
xcconfig.to_hash['FRAMEWORK_SEARCH_PATHS'].should == '$(inherited) "$(PLATFORM_DIR)/Developer/Library/Frameworks"'
generator = PodTargetSettings.new(@banana_pod_target, nil, :configuration => :debug)
xcconfig = generator.generate
xcconfig.to_hash['FRAMEWORK_SEARCH_PATHS'].should == '$(inherited) "$(PLATFORM_DIR)/Developer/Library/Frameworks"'
end
it 'adds correct header search paths for dependent and test targets without modular headers' do
@monkey_pod_target.build_headers.add_search_path('monkey', Platform.ios)
@monkey_pod_target.sandbox.public_headers.add_search_path('monkey', Platform.ios)
@banana_pod_target.build_headers.add_search_path('BananaLib', Platform.ios)
@banana_pod_target.sandbox.public_headers.add_search_path('BananaLib', Platform.ios)
@coconut_pod_target.stubs(:uses_modular_headers?).returns(false)
@coconut_pod_target.stubs(:defines_module?).returns(false)
@coconut_pod_target.build_headers.add_search_path('CoconutLib', Platform.ios)
@coconut_pod_target.sandbox.public_headers.add_search_path('CoconutLib', Platform.ios)
@coconut_pod_target.test_dependent_targets_by_spec_name = { @coconut_test_spec.name => [@monkey_pod_target] }
@coconut_pod_target.dependent_targets = [@banana_pod_target]
generator = PodTargetSettings.new(@coconut_pod_target, @coconut_test_spec, :configuration => :debug)
xcconfig = generator.generate
xcconfig.to_hash['HEADER_SEARCH_PATHS'].should == '$(inherited) "${PODS_ROOT}/Headers/Private"' \
' "${PODS_ROOT}/Headers/Private/CoconutLib"' \
' "${PODS_ROOT}/Headers/Public"' \
' "${PODS_ROOT}/Headers/Public/BananaLib"' \
' "${PODS_ROOT}/Headers/Public/CoconutLib"' \
' "${PODS_ROOT}/Headers/Public/monkey"'
end
it 'adds correct header search paths for dependent and test targets for non test xcconfigs without modular headers' do
@monkey_pod_target.build_headers.add_search_path('monkey', Platform.ios)
@monkey_pod_target.sandbox.public_headers.add_search_path('monkey', Platform.ios)
@banana_pod_target.build_headers.add_search_path('BananaLib', Platform.ios)
@banana_pod_target.sandbox.public_headers.add_search_path('BananaLib', Platform.ios)
@coconut_pod_target.stubs(:uses_modular_headers?).returns(false)
@coconut_pod_target.stubs(:defines_module?).returns(false)
@coconut_pod_target.build_headers.add_search_path('CoconutLib', Platform.ios)
@coconut_pod_target.sandbox.public_headers.add_search_path('CoconutLib', Platform.ios)
@coconut_pod_target.test_dependent_targets_by_spec_name = { @coconut_test_spec.name => [@monkey_pod_target] }
@coconut_pod_target.dependent_targets = [@banana_pod_target]
# This is not an test xcconfig so it should exclude header search paths for the 'monkey' pod
generator = PodTargetSettings.new(@coconut_pod_target, nil, :configuration => :debug)
xcconfig = generator.generate
xcconfig.to_hash['HEADER_SEARCH_PATHS'].should == '$(inherited) "${PODS_ROOT}/Headers/Private"' \
' "${PODS_ROOT}/Headers/Private/CoconutLib"' \
' "${PODS_ROOT}/Headers/Public"' \
' "${PODS_ROOT}/Headers/Public/BananaLib"' \
' "${PODS_ROOT}/Headers/Public/CoconutLib"' \
end
it 'adds correct header search paths for dependent and test targets with modular headers' do
@monkey_pod_target.build_headers.add_search_path('monkey', Platform.ios)
@monkey_pod_target.sandbox.public_headers.add_search_path('monkey', Platform.ios)
@banana_pod_target.build_headers.add_search_path('BananaLib', Platform.ios)
@banana_pod_target.sandbox.public_headers.add_search_path('BananaLib', Platform.ios)
@coconut_pod_target.stubs(:uses_modular_headers?).returns(true)
@coconut_pod_target.stubs(:defines_module?).returns(true)
@coconut_pod_target.build_headers.add_search_path('CoconutLib', Platform.ios)
@coconut_pod_target.sandbox.public_headers.add_search_path('CoconutLib', Platform.ios)
@coconut_pod_target.test_dependent_targets_by_spec_name = { @coconut_test_spec.name => [@monkey_pod_target] }
@coconut_pod_target.dependent_targets = [@banana_pod_target]
generator = PodTargetSettings.new(@coconut_pod_target, @coconut_test_spec, :configuration => :debug)
xcconfig = generator.generate
xcconfig.to_hash['HEADER_SEARCH_PATHS'].should == '$(inherited) "${PODS_ROOT}/Headers/Private"' \
' "${PODS_ROOT}/Headers/Private/CoconutLib"' \
' "${PODS_ROOT}/Headers/Public"' \
end
it 'adds correct header search paths for dependent and test targets for non test xcconfigs with modular headers' do
@monkey_pod_target.build_headers.add_search_path('monkey', Platform.ios)
@monkey_pod_target.sandbox.public_headers.add_search_path('monkey', Platform.ios)
@banana_pod_target.build_headers.add_search_path('BananaLib', Platform.ios)
@banana_pod_target.sandbox.public_headers.add_search_path('BananaLib', Platform.ios)
@coconut_pod_target.stubs(:uses_modular_headers?).returns(true)
@coconut_pod_target.stubs(:defines_module?).returns(true)
@coconut_pod_target.build_headers.add_search_path('CoconutLib', Platform.ios)
@coconut_pod_target.sandbox.public_headers.add_search_path('CoconutLib', Platform.ios)
@coconut_pod_target.test_dependent_targets_by_spec_name = { @coconut_test_spec.name => [@monkey_pod_target] }
@coconut_pod_target.dependent_targets = [@banana_pod_target]
generator = PodTargetSettings.new(@coconut_pod_target, nil, :configuration => :debug)
xcconfig = generator.generate
xcconfig.to_hash['HEADER_SEARCH_PATHS'].should == '$(inherited) "${PODS_ROOT}/Headers/Private"' \
' "${PODS_ROOT}/Headers/Private/CoconutLib"' \
' "${PODS_ROOT}/Headers/Public"' \
end
it 'does not include other ld flags for test dependent targets if its not a test xcconfig' do
@coconut_pod_target.test_dependent_targets_by_spec_name = { @coconut_test_spec.name => [@monkey_pod_target] }
generator = PodTargetSettings.new(@coconut_pod_target, nil, :configuration => :debug)
xcconfig = generator.generate
xcconfig.to_hash['LIBRARY_SEARCH_PATHS'].should.be.nil
xcconfig.to_hash['OTHER_LDFLAGS'].should.be.nil
end
it 'includes default runpath search path list for test xcconfigs' do
generator = PodTargetSettings.new(@coconut_pod_target, @coconut_test_spec, :configuration => :debug)
xcconfig = generator.generate
xcconfig.to_hash['LD_RUNPATH_SEARCH_PATHS'].should == "$(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks'"
end
it 'includes default runpath search path list for test xcconfigs for test bundle' do
@coconut_pod_target.stubs(:platform).returns(Platform.new(:osx, '10.10'))
generator = PodTargetSettings.new(@coconut_pod_target, @coconut_test_spec, :configuration => :debug)
xcconfig = generator.generate
xcconfig.to_hash['LD_RUNPATH_SEARCH_PATHS'].should == "$(inherited) '@executable_path/../Frameworks' '@loader_path/../Frameworks'"
end
it 'does not set configuration build dir for test xcconfigs' do
generator = PodTargetSettings.new(@coconut_pod_target, @coconut_test_spec, :configuration => :debug)
xcconfig = generator.generate
xcconfig.to_hash['CONFIGURATION_BUILD_DIR'].should.be.nil
end
end
end
end
end
end