-
Notifications
You must be signed in to change notification settings - Fork 2.6k
/
target_validator_spec.rb
634 lines (562 loc) · 32.6 KB
/
target_validator_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
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
require File.expand_path('../../../../spec_helper', __FILE__)
module Pod
class Installer
class Xcode
describe TargetValidator do
# @return [Lockfile]
#
def generate_lockfile(lockfile_version: Pod::VERSION)
hash = {}
hash['PODS'] = []
hash['DEPENDENCIES'] = []
hash['SPEC CHECKSUMS'] = {}
hash['COCOAPODS'] = lockfile_version
Pod::Lockfile.new(hash)
end
# @return [AnalysisResult]
#
def create_validator(sandbox, podfile, lockfile)
sandbox.specifications_root.mkpath
@analyzer = Analyzer.new(sandbox, podfile, lockfile, nil, true, false)
result = @analyzer.analyze
aggregate_targets = result.targets
pod_targets = aggregate_targets.flat_map(&:pod_targets).uniq
TargetValidator.new(aggregate_targets, pod_targets, podfile.installation_options)
end
describe '#verify_no_duplicate_framework_and_library_names' do
before do
SpecHelper.create_sample_app_copy_from_fixture('Sample Extensions Project')
end
it 'detects duplicate library names' do
Sandbox::FileAccessor.any_instance.stubs(:vendored_libraries).
returns([Pathname('a/libBananaStaticLib.a')]).then.
returns([Pathname('b/libBananaStaticLib.a')])
Pod::Specification.any_instance.stubs(:dependencies).returns([])
fixture_path = ROOT + 'spec/fixtures'
config.repos_dir = fixture_path + 'spec-repos'
podfile = Pod::Podfile.new do
platform :ios, '8.0'
install! 'cocoapods', :integrate_targets => false
project(fixture_path + 'SampleProject/SampleProject').to_s
pod 'monkey', :path => (fixture_path + 'monkey').to_s
pod 'BananaLib', :path => (fixture_path + 'banana-lib').to_s
target 'SampleProject'
end
lockfile = generate_lockfile
@validator = create_validator(config.sandbox, podfile, lockfile)
should.raise(Informative) { @validator.validate! }.message.should.match /conflict.*bananastaticlib/
end
it 'detects duplicate framework names' do
Sandbox::FileAccessor.any_instance.stubs(:vendored_frameworks).
returns([Pathname('a/monkey.framework')]).then.
returns([Pathname('b/monkey.framework')]).then.
returns([Pathname('c/monkey.framework')])
fixture_path = ROOT + 'spec/fixtures'
config.repos_dir = fixture_path + 'spec-repos'
podfile = Pod::Podfile.new do
platform :ios, '8.0'
install! 'cocoapods', :integrate_targets => false
project(fixture_path + 'SampleProject/SampleProject').to_s
pod 'BananaLib', :path => (fixture_path + 'banana-lib').to_s
pod 'OrangeFramework', :path => (fixture_path + 'orange-framework').to_s
pod 'matryoshka', :path => (fixture_path + 'matryoshka').to_s
pod 'monkey', :path => (fixture_path + 'monkey').to_s
target 'SampleProject'
end
lockfile = generate_lockfile
@validator = create_validator(config.sandbox, podfile, lockfile)
should.raise(Informative) { @validator.validate! }.message.should.match /conflict.*monkey/
end
it 'allows duplicate references to the same expanded framework path' do
Sandbox::FileAccessor.any_instance.stubs(:vendored_frameworks).returns([fixture('monkey/dynamic-monkey.framework')])
Pod::Xcode::LinkageAnalyzer.stubs(:dynamic_binary?).returns(true)
fixture_path = ROOT + 'spec/fixtures'
config.repos_dir = fixture_path + 'spec-repos'
podfile = Pod::Podfile.new do
platform :ios, '8.0'
install! 'cocoapods', :integrate_targets => false
project(fixture_path + 'SampleProject/SampleProject').to_s
use_frameworks!
pod 'BananaLib', :path => (fixture_path + 'banana-lib').to_s
pod 'monkey', :path => (fixture_path + 'monkey').to_s
target 'SampleProject'
end
lockfile = generate_lockfile
@validator = create_validator(config.sandbox, podfile, lockfile)
should.not.raise(Informative) { @validator.validate! }
end
it 'including multiple subspecs from the same pod in a target does not result in duplicate frameworks' do
fixture_path = ROOT + 'spec/fixtures'
config.repos_dir = fixture_path + 'spec-repos'
podfile = Pod::Podfile.new do
platform :ios, '9.3'
project(fixture_path + 'Sample Extensions Project/Sample Extensions Project').to_s
use_frameworks!
target 'Sample Extensions Project' do
pod 'matryoshka/Foo', :path => (fixture_path + 'matryoshka').to_s
pod 'matryoshka', :path => (fixture_path + 'matryoshka').to_s
end
target 'Today Extension' do
pod 'matryoshka/Foo', :path => (fixture_path + 'matryoshka').to_s
end
end
lockfile = generate_lockfile
@validator = create_validator(config.sandbox, podfile, lockfile)
should.not.raise(Informative) { @validator.validate! }
end
end
#-------------------------------------------------------------------------#
describe '#verify_no_static_framework_transitive_dependencies' do
before do
fixture_path = ROOT + 'spec/fixtures'
config.repos_dir = fixture_path + 'spec-repos'
@podfile = Pod::Podfile.new do
install! 'cocoapods', 'integrate_targets' => false
platform :ios, '8.0'
project(fixture_path + 'SampleProject/SampleProject').to_s
use_frameworks!
pod 'BananaLib', :path => (fixture_path + 'banana-lib').to_s
pod 'CoconutLib', :path => (fixture_path + 'coconut-lib').to_s
pod 'OrangeFramework', :path => (fixture_path + 'orange-framework').to_s
pod 'matryoshka', :path => (fixture_path + 'matryoshka').to_s
pod 'monkey', :path => (fixture_path + 'monkey').to_s
target 'SampleProject'
end
@podfile.target_definitions['SampleProject'].stubs(:swift_version).returns('3.0')
@lockfile = generate_lockfile
@file = Pathname('/yolo.m')
@file.stubs(:realpath).returns(@file)
@lib_thing = Pathname('/libThing.a')
@lib_thing.stubs(:realpath).returns(@lib_thing)
end
it 'detects transitive static dependencies which are linked directly to the user target' do
@validator = create_validator(config.sandbox, @podfile, @lockfile)
should.raise(Informative) { @validator.validate! }.message.should.match /transitive.*monkey.a/
end
it 'detects transitive static dependencies which are linked directly to the user target with stubbing' do
Sandbox::FileAccessor.any_instance.stubs(:vendored_libraries).returns([@lib_thing])
@validator = create_validator(config.sandbox, @podfile, @lockfile)
should.raise(Informative) { @validator.validate! }.message.should.match /transitive.*libThing/
end
it 'allows transitive static dependencies which contain other source code' do
Sandbox::FileAccessor.any_instance.stubs(:source_files).returns([@file])
Sandbox::FileAccessor.any_instance.stubs(:vendored_libraries).returns([@lib_thing])
@validator = create_validator(config.sandbox, @podfile, @lockfile)
should.not.raise(Informative) { @validator.validate! }
end
it 'allows transitive static dependencies when both dependencies are linked against the user target' do
PodTarget.any_instance.stubs(:should_build? => false)
Sandbox::FileAccessor.any_instance.stubs(:vendored_libraries).returns([@lib_thing])
@validator = create_validator(config.sandbox, @podfile, @lockfile)
should.not.raise(Informative) { @validator.validate! }
end
end
describe '#verify_no_incorrect_static_framework_transitive_dependencies_with_static_frameworks' do
before do
fixture_path = ROOT + 'spec/fixtures'
config.repos_dir = fixture_path + 'spec-repos'
@podfile = Pod::Podfile.new do
install! 'cocoapods', 'integrate_targets' => false
platform :ios, '8.0'
project(fixture_path + 'SampleProject/SampleProject').to_s
use_frameworks!
pod 'BananaLib', :path => (fixture_path + 'banana-lib').to_s
pod 'CoconutLib', :path => (fixture_path + 'coconut-lib').to_s
pod 'OrangeFramework', :path => (fixture_path + 'orange-framework').to_s
pod 'matryoshka', :path => (fixture_path + 'static-matryoshka').to_s
pod 'monkey', :path => (fixture_path + 'monkey').to_s
target 'SampleProject'
end
@podfile.target_definitions['SampleProject'].stubs(:swift_version).returns('3.0')
@lockfile = generate_lockfile
@file = Pathname('/yolo.m')
@file.stubs(:realpath).returns(@file)
@lib_thing = Pathname('/libThing.a')
@lib_thing.stubs(:realpath).returns(@lib_thing)
end
it 'detects transitive static dependencies which are linked directly to the user target' do
@validator = create_validator(config.sandbox, @podfile, @lockfile)
should.raise(Informative) { @validator.validate! }.message.should.match /transitive.*monkey.a/
end
it 'detects transitive static dependencies which are linked directly to the user target with stubbing' do
Sandbox::FileAccessor.any_instance.stubs(:vendored_libraries).returns([@lib_thing])
@validator = create_validator(config.sandbox, @podfile, @lockfile)
should.raise(Informative) { @validator.validate! }.message.should.match /transitive.*libThing/
end
it 'detects transitive static dependencies to static frameworks from dynamic library pods' do
Sandbox::FileAccessor.any_instance.stubs(:source_files).returns([@file])
Sandbox::FileAccessor.any_instance.stubs(:vendored_libraries).returns([@lib_thing])
@validator = create_validator(config.sandbox, @podfile, @lockfile)
should.raise(Informative) { @validator.validate! }.message.should.match /transitive.*matryoshka/
end
it 'allows transitive static dependencies when both dependencies are linked against the user target' do
PodTarget.any_instance.stubs(:should_build? => false)
Sandbox::FileAccessor.any_instance.stubs(:vendored_libraries).returns([@lib_thing])
@validator = create_validator(config.sandbox, @podfile, @lockfile)
should.not.raise(Informative) { @validator.validate! }
end
it 'allows transitive static dependencies when building a static framework' do
PodTarget.any_instance.stubs(:build_type => BuildType.static_framework)
Sandbox::FileAccessor.any_instance.stubs(:vendored_libraries).returns([@lib_thing])
@validator = create_validator(config.sandbox, @podfile, @lockfile)
should.not.raise(Informative) { @validator.validate! }
end
end
describe '#verify_no_static_framework_transitive_dependencies_with_static_framework' do
before do
fixture_path = ROOT + 'spec/fixtures'
config.repos_dir = fixture_path + 'spec-repos'
@podfile = Pod::Podfile.new do
install! 'cocoapods', 'integrate_targets' => false
platform :ios, '8.0'
project(fixture_path + 'SampleProject/SampleProject').to_s
use_frameworks!
pod 'matryoshka', :path => (fixture_path + 'static-matryoshka').to_s
pod 'monkey', :path => (fixture_path + 'monkey').to_s
target 'SampleProject'
end
@lockfile = generate_lockfile
@file = Pathname('/yolo.m')
@file.stubs(:realpath).returns(@file)
end
it 'allows transitive static dependencies when building a static framework' do
@validator = create_validator(config.sandbox, @podfile, @lockfile)
should.not.raise(Informative) { @validator.send :verify_no_static_framework_transitive_dependencies }
end
end
#-------------------------------------------------------------------------#
describe '#verify_swift_pods_swift_version' do
it 'raises when targets integrate the same swift pod but have different swift versions' do
fixture_path = ROOT + 'spec/fixtures'
config.repos_dir = fixture_path + 'spec-repos'
podfile = Podfile.new do
project(fixture_path + 'SampleProject/SampleProject').to_s
platform :ios, '8.0'
install! 'cocoapods', :integrate_targets => false
use_frameworks!
pod 'OrangeFramework', :path => (fixture_path + 'orange-framework').to_s
pod 'matryoshka', :path => (fixture_path + 'matryoshka').to_s
target 'SampleProject'
target 'TestRunner'
end
lockfile = generate_lockfile
@validator = create_validator(config.sandbox, podfile, lockfile)
podfile.target_definition_list.find { |td| td.name == 'SampleProject' }.swift_version = '3.0'
podfile.target_definition_list.find { |td| td.name == 'TestRunner' }.swift_version = '2.3'
e = should.raise Informative do
@validator.validate!
end
e.message.should.match /Unable to determine Swift version for the following pods:/
e.message.should.include '`OrangeFramework` is integrated by multiple targets that use a different Swift version: ' \
'`SampleProject` (Swift 3.0) and `TestRunner` (Swift 2.3).'
e.message.should.not.include '`matryoshka` is integrated by multiple targets that use a different Swift version: ' \
'`SampleProject` (Swift 3.0) and `TestRunner` (Swift 2.3).'
end
it 'raises when swift pods integrated into targets that do not specify a swift version' do
fixture_path = ROOT + 'spec/fixtures'
config.repos_dir = fixture_path + 'spec-repos'
podfile = Podfile.new do
project(fixture_path + 'SampleProject/SampleProject').to_s
use_frameworks!
platform :ios, '8.0'
install! 'cocoapods', :integrate_targets => false
pod 'OrangeFramework', :path => (fixture_path + 'orange-framework').to_s
pod 'matryoshka', :path => (fixture_path + 'matryoshka').to_s
target 'SampleProject'
target 'TestRunner'
end
lockfile = generate_lockfile
@validator = create_validator(config.sandbox, podfile, lockfile)
e = should.raise Informative do
@validator.validate!
end
e.message.should.match /Unable to determine Swift version for the following pods:/
e.message.should.include '`OrangeFramework` does not specify a Swift version and none of the targets ' \
'(`SampleProject` and `TestRunner`) integrating it have the `SWIFT_VERSION` attribute set. Please contact ' \
'the author or set the `SWIFT_VERSION` attribute in at least one of the targets that integrate this pod.'
e.message.should.not.include '`matryoshka` does not specify a Swift version and none of the targets ' \
'(`SampleProject` and `TestRunner`) integrating it have the `SWIFT_VERSION` attribute set. Please contact ' \
'the author or set the `SWIFT_VERSION` attribute in at least one of the targets that integrate this pod.'
end
it 'does not raise when targets integrate the same pod but only one of the targets is a swift target' do
fixture_path = ROOT + 'spec/fixtures'
config.repos_dir = fixture_path + 'spec-repos'
podfile = Podfile.new do
project 'SampleProject/SampleProject'
use_frameworks!
platform :ios, '8.0'
install! 'cocoapods', :integrate_targets => false
pod 'OrangeFramework', :path => (fixture_path + 'orange-framework').to_s
pod 'matryoshka', :path => (fixture_path + 'matryoshka').to_s
target 'SampleProject' do
current_target_definition.swift_version = '3.0'
end
target 'TestRunner'
end
lockfile = generate_lockfile
@validator = create_validator(config.sandbox, podfile, lockfile)
lambda { @validator.validate! }.should.not.raise
end
it 'does not raise when targets integrate the same pod but none of the pod targets use swift' do
fixture_path = ROOT + 'spec/fixtures'
config.repos_dir = fixture_path + 'spec-repos'
podfile = Podfile.new do
project(fixture_path + 'SampleProject/SampleProject').to_s
use_frameworks!
platform :ios, '8.0'
install! 'cocoapods', :integrate_targets => false
pod 'matryoshka', :path => (fixture_path + 'matryoshka').to_s
target 'SampleProject'
target 'TestRunner'
end
lockfile = generate_lockfile
@validator = create_validator(config.sandbox, podfile, lockfile)
podfile.target_definition_list.find { |td| td.name == 'SampleProject' }.swift_version = '3.0'
podfile.target_definition_list.find { |td| td.name == 'TestRunner' }.swift_version = '2.3'
lambda { @validator.validate! }.should.not.raise
end
it 'does not raise when targets with different Swift versions integrate the same pod that specifies swift version attribute' do
fixture_path = ROOT + 'spec/fixtures'
config.repos_dir = fixture_path + 'spec-repos'
podfile = Podfile.new do
project(fixture_path + 'SampleProject/SampleProject').to_s
use_frameworks!
platform :ios, '8.0'
install! 'cocoapods', :integrate_targets => false
pod 'OrangeFramework', :path => (fixture_path + 'orange-framework').to_s
pod 'matryoshka', :path => (fixture_path + 'matryoshka').to_s
target 'SampleProject'
target 'TestRunner'
end
lockfile = generate_lockfile
@validator = create_validator(config.sandbox, podfile, lockfile)
podfile.target_definition_list.find { |td| td.name == 'SampleProject' }.swift_version = '3.0'
podfile.target_definition_list.find { |td| td.name == 'TestRunner' }.swift_version = '2.3'
@validator.pod_targets.find { |pt| pt.name == 'OrangeFramework' }.stubs(:spec_swift_versions).returns(['4.0'])
@validator.pod_targets.find { |pt| pt.name == 'OrangeFramework' }.stubs(:swift_version).returns('4.0')
@validator.pod_targets.find { |pt| pt.name == 'matryoshka' }.stubs(:spec_swift_versions).returns(['3.2'])
@validator.pod_targets.find { |pt| pt.name == 'matryoshka' }.stubs(:swift_version).returns('3.2')
lambda { @validator.validate! }.should.not.raise
end
it 'raises an error if a pods swift versions are not satisfied by the targets of the requirements' do
fixture_path = ROOT + 'spec/fixtures'
config.repos_dir = fixture_path + 'spec-repos'
podfile = Podfile.new do
project(fixture_path + 'SampleProject/SampleProject').to_s
platform :ios, '10.0'
install! 'cocoapods', :integrate_targets => false
pod 'MultiSwift', :path => (fixture_path + 'multi-swift').to_s
supports_swift_versions '< 3.0'
target 'SampleProject'
target 'TestRunner'
end
lockfile = generate_lockfile
@validator = create_validator(config.sandbox, podfile, lockfile)
e = should.raise Informative do
@validator.validate!
end
e.message.should.match /Unable to determine Swift version for the following pods:/
e.message.should.include 'MultiSwift` does not specify a Swift version (`3.2` and `4.0`) that is satisfied by ' \
'any of targets (`SampleProject` and `TestRunner`) integrating it.'
end
it 'does not crash on swift version check with deduplicate_targets' do
fixture_path = ROOT + 'spec/fixtures'
config.repos_dir = fixture_path + 'spec-repos'
podfile = Podfile.new do
project(fixture_path + 'SampleProject/SampleProject').to_s
platform :ios, '10.0'
install! 'cocoapods', :integrate_targets => false, :deduplicate_targets => false
pod 'MultiSwift', :path => (fixture_path + 'multi-swift').to_s
supports_swift_versions '< 3.0'
target 'SampleProject'
target 'TestRunner'
end
lockfile = generate_lockfile
@validator = create_validator(config.sandbox, podfile, lockfile)
e = should.raise Informative do
@validator.validate!
end
e.message.should.match /Unable to determine Swift version for the following pods:/
e.message.should.include 'MultiSwift-Pods-SampleProject` does not specify a Swift version (`3.2` and `4.0`) that is satisfied by ' \
'any of targets (`SampleProject`) integrating it.'
e.message.should.include 'MultiSwift-Pods-TestRunner` does not specify a Swift version (`3.2` and `4.0`) that is satisfied by ' \
'any of targets (`TestRunner`) integrating it.'
end
it 'does not crash if targets are missing' do
fixture_path = ROOT + 'spec/fixtures'
config.repos_dir = fixture_path + 'spec-repos'
podfile = Podfile.new do
project(fixture_path + 'SampleProject/SampleProject').to_s
platform :ios, '10.0'
install! 'cocoapods', :integrate_targets => false
end
lockfile = generate_lockfile
@validator = create_validator(config.sandbox, podfile, lockfile)
@validator.stubs(:pod_targets).returns([stub('MultiSwift',
:uses_swift? => true,
:should_build? => true,
:swift_version => nil,
:dependent_targets => [],
:spec_swift_versions => ['4.0'])])
lambda { @validator.validate! }.should.not.raise
end
it 'does not raise an error if a pods swift versions are satisfied by the targets requirements' do
fixture_path = ROOT + 'spec/fixtures'
config.repos_dir = fixture_path + 'spec-repos'
podfile = Podfile.new do
project(fixture_path + 'SampleProject/SampleProject').to_s
platform :ios, '10.0'
install! 'cocoapods', :integrate_targets => false
pod 'MultiSwift', :path => (fixture_path + 'multi-swift').to_s
supports_swift_versions '> 3.0'
target 'SampleProject'
target 'TestRunner'
end
lockfile = generate_lockfile
@validator = create_validator(config.sandbox, podfile, lockfile)
lambda { @validator.validate! }.should.not.raise
end
end
describe '#verify_swift_pods_have_module_dependencies' do
it 'raises when a swift target depends upon a target that does not define a module' do
fixture_path = ROOT + 'spec/fixtures'
config.repos_dir = fixture_path + 'spec-repos'
podfile = Podfile.new do
project(fixture_path + 'SampleProject/SampleProject').to_s
platform :ios, '10.0'
install! 'cocoapods', :integrate_targets => false
pod 'OrangeFramework', :path => (fixture_path + 'orange-framework').to_s, :modular_headers => true
pod 'matryoshka', :path => (fixture_path + 'matryoshka').to_s, :modular_headers => false
target 'SampleProject'
target 'TestRunner'
end
lockfile = generate_lockfile
@validator = create_validator(config.sandbox, podfile, lockfile)
@validator.pod_targets.find { |pt| pt.name == 'OrangeFramework' }.stubs(:spec_swift_versions).returns(['4.0'])
@validator.pod_targets.find { |pt| pt.name == 'OrangeFramework' }.stubs(:swift_version).returns('4.0')
e = lambda { @validator.validate! }.should.raise Informative
e.message.should.include <<-EOS.strip_heredoc.strip
[!] The following Swift pods cannot yet be integrated as static libraries:
The Swift pod `OrangeFramework` depends upon `matryoshka`, which does not define modules. To opt into those targets generating module maps (which is necessary to import them from Swift when building as static libraries), you may set `use_modular_headers!` globally in your Podfile, or specify `:modular_headers => true` for particular dependencies.
EOS
end
it 'does not raise when a swift target depends upon a target that is not built' do
fixture_path = ROOT + 'spec/fixtures'
config.repos_dir = fixture_path + 'spec-repos'
podfile = Podfile.new do
project(fixture_path + 'SampleProject/SampleProject').to_s
platform :ios, '10.0'
install! 'cocoapods', :integrate_targets => false
pod 'OrangeFramework', :path => (fixture_path + 'orange-framework').to_s, :modular_headers => true
pod 'matryoshka', :path => (fixture_path + 'matryoshka').to_s
target 'SampleProject'
target 'TestRunner'
end
lockfile = generate_lockfile
@validator = create_validator(config.sandbox, podfile, lockfile)
podfile.target_definition_list.find { |td| td.name == 'SampleProject' }.swift_version = '3.0'
podfile.target_definition_list.find { |td| td.name == 'TestRunner' }.swift_version = '3.0'
@validator.pod_targets.find { |pt| pt.name == 'matryoshka' }.stubs(:should_build?).returns(false)
lambda { @validator.validate! }.should.not.raise
end
it 'does not raise when a pre built swift target depends upon a target that requires building' do
fixture_path = ROOT + 'spec/fixtures'
config.repos_dir = fixture_path + 'spec-repos'
podfile = Podfile.new do
project(fixture_path + 'SampleProject/SampleProject').to_s
platform :ios, '12.0'
install! 'cocoapods', :integrate_targets => false
pod 'VendoredSwiftFramework', :path => (fixture_path + 'prebuilt-swift-framework').to_s
pod 'matryoshka', :path => (fixture_path + 'matryoshka').to_s
target 'SampleProject'
target 'TestRunner'
end
lockfile = generate_lockfile
@validator = create_validator(config.sandbox, podfile, lockfile)
podfile.target_definition_list.find { |td| td.name == 'SampleProject' }.swift_version = '3.0'
podfile.target_definition_list.find { |td| td.name == 'TestRunner' }.swift_version = '3.0'
vendored_swift_framework_pod_target = @validator.pod_targets.find { |pt| pt.name == 'VendoredSwiftFramework' }
matryoshka_pod_target = @validator.pod_targets.find { |pt| pt.name == 'matryoshka' }
vendored_swift_framework_pod_target.stubs(:dependent_targets).returns([matryoshka_pod_target])
lambda { @validator.validate! }.should.not.raise
end
end
describe '#verify_no_multiple_project_names' do
it 'does not raise if the project name of a pod is only set once' do
fixture_path = ROOT + 'spec/fixtures'
config.repos_dir = fixture_path + 'spec-repos'
podfile = Podfile.new do
project(fixture_path + 'SampleProject/SampleProject').to_s
platform :ios, '10.0'
install! 'cocoapods', :integrate_targets => false, :generate_multiple_pod_projects => true
pod 'matryoshka', :path => (fixture_path + 'matryoshka').to_s, :project_name => 'CustomProjectName'
target 'SampleProject'
target 'TestRunner'
end
lockfile = generate_lockfile
@validator = create_validator(config.sandbox, podfile, lockfile)
lambda { @validator.validate! }.should.not.raise
end
it 'does not when the same project name is used across all targets' do
fixture_path = ROOT + 'spec/fixtures'
config.repos_dir = fixture_path + 'spec-repos'
podfile = Podfile.new do
project(fixture_path + 'SampleProject/SampleProject').to_s
platform :ios, '10.0'
install! 'cocoapods', :integrate_targets => false, :generate_multiple_pod_projects => true
target 'SampleProject' do
pod 'matryoshka', :path => (fixture_path + 'matryoshka').to_s, :project_name => 'ProjectName1'
end
target 'TestRunner' do
pod 'matryoshka', :path => (fixture_path + 'matryoshka').to_s, :project_name => 'ProjectName1'
end
end
lockfile = generate_lockfile
@validator = create_validator(config.sandbox, podfile, lockfile)
lambda { @validator.validate! }.should.not.raise
end
it 'raises when two different project names for a pod are specified with multiple projects option enabled' do
fixture_path = ROOT + 'spec/fixtures'
config.repos_dir = fixture_path + 'spec-repos'
podfile = Podfile.new do
project(fixture_path + 'SampleProject/SampleProject').to_s
platform :ios, '10.0'
install! 'cocoapods', :integrate_targets => false, :generate_multiple_pod_projects => true
target 'SampleProject' do
pod 'matryoshka', :path => (fixture_path + 'matryoshka').to_s, :project_name => 'ProjectName1'
end
target 'TestRunner' do
pod 'matryoshka', :path => (fixture_path + 'matryoshka').to_s, :project_name => 'ProjectName2'
end
end
lockfile = generate_lockfile
@validator = create_validator(config.sandbox, podfile, lockfile)
e = lambda { @validator.validate! }.should.raise Informative
e.message.should.include <<-EOS.strip_heredoc.strip
[!] The following pods cannot be integrated:
- `matryoshka` specifies multiple project names (`ProjectName1` and `ProjectName2`) in different targets (`SampleProject` and `TestRunner`).
EOS
end
it 'does not raise when two different project names for a pod are specified with multiple project option disabled' do
fixture_path = ROOT + 'spec/fixtures'
config.repos_dir = fixture_path + 'spec-repos'
podfile = Podfile.new do
project(fixture_path + 'SampleProject/SampleProject').to_s
platform :ios, '10.0'
install! 'cocoapods', :integrate_targets => false, :generate_multiple_pod_projects => false
target 'SampleProject' do
pod 'matryoshka', :path => (fixture_path + 'matryoshka').to_s, :project_name => 'ProjectName1'
end
target 'TestRunner' do
pod 'matryoshka', :path => (fixture_path + 'matryoshka').to_s, :project_name => 'ProjectName2'
end
end
lockfile = generate_lockfile
@validator = create_validator(config.sandbox, podfile, lockfile)
lambda { @validator.validate! }.should.not.raise
end
end
end
end
end
end