-
Notifications
You must be signed in to change notification settings - Fork 2.6k
/
pod_target_installer_spec.rb
1769 lines (1540 loc) · 99.2 KB
/
pod_target_installer_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
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
require File.expand_path('../../../../../spec_helper', __FILE__)
module Pod
class Installer
class Xcode
class PodsProjectGenerator
describe PodTargetInstaller do
describe 'In General' do
before do
@banana_spec = fixture_spec('banana-lib/BananaLib.podspec')
@project = Pod::Project.new(config.sandbox.project_path)
@project.add_pod_group('BananaLib', fixture('banana-lib'))
platform = Platform.new(:ios, '4.3')
@target_definition = fixture_target_definition('SampleProject', platform)
@pod_target = fixture_pod_target(@banana_spec, BuildType.static_library,
{ 'Debug' => :debug, 'Release' => :release }, [], platform,
[@target_definition])
FileReferencesInstaller.new(config.sandbox, [@pod_target], @project).install!
@installer = PodTargetInstaller.new(config.sandbox, @project, @pod_target)
end
it 'sets the platform and the deployment target for iOS targets' do
@installer.install!
target = @project.targets.first
target.platform_name.should == :ios
target.deployment_target.should == '4.3'
target.build_settings('Debug')['IPHONEOS_DEPLOYMENT_TARGET'].should == '4.3'
end
it 'sets the platform and the deployment target for iOS targets that require frameworks' do
@pod_target.stubs(:platform).returns(Platform.new(:ios, '8.0'))
@pod_target.stubs(:build_type).returns(BuildType.dynamic_framework)
@installer.install!
target = @project.targets.first
target.platform_name.should == :ios
target.deployment_target.should == '8.0'
target.build_settings('Debug')['IPHONEOS_DEPLOYMENT_TARGET'].should == '8.0'
end
it 'sets the platform and the deployment target for OS X targets' do
@pod_target.stubs(:platform).returns(Platform.new(:osx, '10.6'))
@installer.install!
target = @project.targets.first
target.platform_name.should == :osx
target.deployment_target.should == '10.6'
target.build_settings('Debug')['MACOSX_DEPLOYMENT_TARGET'].should == '10.6'
end
it "adds the user's build configurations to the target" do
@pod_target.user_build_configurations.merge!('AppStore' => :release, 'Test' => :debug)
@installer.install!
@project.targets.first.build_configurations.map(&:name).sort.should == %w(AppStore Debug Release Test)
end
it 'it creates different hash instances for the build settings of various build configurations' do
@installer.install!
build_settings = @project.targets.first.build_configurations.map(&:build_settings)
build_settings.map(&:object_id).uniq.count.should == 2
end
it 'does not enable the GCC_WARN_INHIBIT_ALL_WARNINGS flag by default' do
@installer.install!.native_target.build_configurations.each do |config|
config.build_settings['GCC_WARN_INHIBIT_ALL_WARNINGS'].should.be.nil
end
end
it 'sets an empty codesigning identity for iOS/tvOS/watchOS' do
@installer.install!
@project.targets.first.build_configurations.each do |config|
config.build_settings['CODE_SIGN_IDENTITY[sdk=appletvos*]'].should == ''
config.build_settings['CODE_SIGN_IDENTITY[sdk=iphoneos*]'].should == ''
config.build_settings['CODE_SIGN_IDENTITY[sdk=watchos*]'].should == ''
end
end
it 'respects INFOPLIST_FILE of pod_target_xcconfig' do
@banana_spec.pod_target_xcconfig = {
'INFOPLIST_FILE' => 'somefile.plist',
}
@installer.install!
@project.targets.first.build_configurations.each do |config|
config.resolve_build_setting('INFOPLIST_FILE').should == 'somefile.plist'
end
end
it 'adds bundle identifier from info_plist to build settings' do
@banana_spec.info_plist = {
'CFBundleIdentifier' => 'some.bundle.id',
}
@installer.install!
@project.targets.first.build_configurations.each do |config|
config.resolve_build_setting('PRODUCT_BUNDLE_IDENTIFIER').should == 'some.bundle.id'
end
end
it 'cleans up temporary directories' do
@installer.expects(:clean_support_files_temp_dir).once
@installer.install!
end
describe 'info_plist_bundle_id' do
it 'cache and return CFBundleIdentifier value when present in info_plist hash' do
@installer.target.root_spec.info_plist = { 'CFBundleIdentifier' => 'CocoaPods.test.id' }
@installer.send(:info_plist_bundle_id).should == 'CocoaPods.test.id'
@installer.instance_variable_get(:@plist_bundle_id).should == 'CocoaPods.test.id'
end
it 'logs warning when CFBundleIdentifier value present in info_plist hash' do
@installer.target.root_spec.info_plist = { 'CFBundleIdentifier' => 'CocoaPods.test.id' }
@installer.send(:info_plist_bundle_id)
UI.warnings.should.include 'The `BananaLib` target ' \
'sets a Bundle Identifier of `CocoaPods.test.id` in it\'s info.plist file. ' \
'The Bundle Identifier should be set using pod_target_xcconfig: ' \
's.pod_target_xcconfig = { \'PRODUCT_BUNDLE_IDENTIFIER\': \'CocoaPods.test.id\' }`.'
end
it 'returns nil with no CFBundleIdentifier info_plist hash' do
@installer.target.root_spec.info_plist = nil
@installer.send(:info_plist_bundle_id).should.nil?
@installer.target.root_spec.info_plist = {}
@installer.send(:info_plist_bundle_id).should.nil?
@installer.instance_variable_get(:@plist_bundle_id).should.nil?
UI.warnings.should.not.include 'The `BananaLib` target ' \
'sets a Bundle Identifier of `CocoaPods.test.id` in it\'s info.plist file. ' \
'The Bundle Identifier should be set using pod_target_xcconfig: ' \
's.pod_target_xcconfig = { \'PRODUCT_BUNDLE_IDENTIFIER\': \'CocoaPods.test.id\' }`.'
end
end
#--------------------------------------#
describe 'headers folder paths' do
it 'does not set them for framework targets' do
@pod_target.stubs(:build_type => BuildType.dynamic_framework)
@installer.install!
@project.targets.first.build_configurations.each do |config|
config.build_settings['PUBLIC_HEADERS_FOLDER_PATH'].should.be.nil
config.build_settings['PRIVATE_HEADERS_FOLDER_PATH'].should.be.nil
end
end
it 'empties them for non-framework targets' do
@installer.install!
@project.targets.first.build_configurations.each do |config|
config.build_settings['PUBLIC_HEADERS_FOLDER_PATH'].should.be.empty
config.build_settings['PRIVATE_HEADERS_FOLDER_PATH'].should.be.empty
end
end
end
#--------------------------------------#
describe 'setting the SWIFT_VERSION' do
it 'does not set the version if not included by the target definition' do
@installer.install!
@project.targets.first.build_configurations.each do |config|
config.build_settings.should.not.include?('SWIFT_VERSION')
end
end
it 'sets the version to the one specified in by the pod target' do
pod_target = fixture_pod_target(@banana_spec, BuildType.static_library,
{ 'Debug' => :debug, 'Release' => :release }, [], Platform.ios,
[@target_definition], nil, '3.0')
installer = PodTargetInstaller.new(config.sandbox, @project, pod_target)
installer.install!
@project.targets.first.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'].should == '3.0'
end
end
end
describe 'non-library target generation' do
before do
@banana_spec = fixture_spec('banana-lib/BananaLib.podspec')
@watermelon_spec = fixture_spec('watermelon-lib/WatermelonLib.podspec')
@project = Project.new(config.sandbox.project_path)
@project.add_pod_group('WatermelonLib', fixture('watermelon-lib'))
@ios_target_definition = fixture_target_definition('SampleProject', Platform.new(:ios, '6.0'))
@osx_target_definition = fixture_target_definition('SampleProject2', Platform.new(:osx, '10.8'))
user_build_configurations = { 'Debug' => :debug, 'Release' => :release }
all_specs = [@watermelon_spec, *@watermelon_spec.recursive_subspecs]
@banana_target = fixture_pod_target_with_specs([@banana_spec], BuildType.dynamic_framework,
user_build_configurations, [],
Platform.new(:ios, '6.0'),
[@ios_target_definition])
@watermelon_ios_pod_target = fixture_pod_target_with_specs(all_specs, BuildType.static_library,
user_build_configurations, [],
Platform.new(:ios, '6.0'),
[@ios_target_definition])
@watermelon_osx_pod_target = fixture_pod_target_with_specs(all_specs, BuildType.static_library,
user_build_configurations, [],
Platform.new(:osx, '10.8'),
[@osx_target_definition])
FileReferencesInstaller.new(config.sandbox, [@watermelon_ios_pod_target, @watermelon_osx_pod_target],
@project).install!
@ios_installer = PodTargetInstaller.new(config.sandbox, @project, @watermelon_ios_pod_target)
@osx_installer = PodTargetInstaller.new(config.sandbox, @project, @watermelon_osx_pod_target)
end
it 'adds the native test target to the project for iOS targets with correct build settings' do
@watermelon_spec.app_specs.each { |s| s.pod_target_xcconfig = {} }
installation_result = @ios_installer.install!
@project.targets.count.should == 9
@project.targets.first.name.should == 'WatermelonLib'
unit_test_native_target = @project.targets[1]
unit_test_native_target.name.should == 'WatermelonLib-Unit-Tests'
unit_test_native_target.product_reference.name.should == 'WatermelonLib-Unit-Tests'
unit_test_native_target.build_configurations.each do |bc|
bc.base_configuration_reference.real_path.basename.to_s.should == "WatermelonLib.unit-tests.#{bc.name.downcase}.xcconfig"
bc.build_settings['PRODUCT_NAME'].should == 'WatermelonLib-Unit-Tests'
bc.build_settings['MACH_O_TYPE'].should.be.nil
bc.build_settings['PRODUCT_MODULE_NAME'].should.be.nil
bc.build_settings['CODE_SIGNING_REQUIRED'].should == 'YES'
bc.build_settings['CODE_SIGNING_ALLOWED'].should == 'YES'
bc.build_settings['CODE_SIGN_IDENTITY'].should == 'iPhone Developer'
bc.build_settings['INFOPLIST_FILE'].should == 'Target Support Files/WatermelonLib/WatermelonLib-Unit-Tests-Info.plist'
bc.build_settings['GCC_PREFIX_HEADER'].should == 'Target Support Files/WatermelonLib/WatermelonLib-Unit-Tests-prefix.pch'
end
unit_test_native_target.symbol_type.should == :unit_test_bundle
ui_test_native_target = @project.targets[2]
ui_test_native_target.name.should == 'WatermelonLib-UI-UITests'
ui_test_native_target.product_reference.name.should == 'WatermelonLib-UI-UITests'
ui_test_native_target.build_configurations.each do |bc|
bc.base_configuration_reference.real_path.basename.to_s.should == "WatermelonLib.ui-uitests.#{bc.name.downcase}.xcconfig"
bc.build_settings['PRODUCT_NAME'].should == 'WatermelonLib-UI-UITests'
bc.build_settings['MACH_O_TYPE'].should.be.nil
bc.build_settings['PRODUCT_MODULE_NAME'].should.be.nil
bc.build_settings['CODE_SIGNING_REQUIRED'].should == 'YES'
bc.build_settings['CODE_SIGNING_ALLOWED'].should == 'YES'
bc.build_settings['CODE_SIGN_IDENTITY'].should == 'iPhone Developer'
bc.build_settings['INFOPLIST_FILE'].should == 'Target Support Files/WatermelonLib/WatermelonLib-UI-UITests-Info.plist'
bc.build_settings['GCC_PREFIX_HEADER'].should == 'Target Support Files/WatermelonLib/WatermelonLib-UI-UITests-prefix.pch'
end
ui_test_native_target.symbol_type.should == :ui_test_bundle
snapshot_test_native_target = @project.targets[3]
snapshot_test_native_target.name.should == 'WatermelonLib-Unit-SnapshotTests'
snapshot_test_native_target.product_reference.name.should == 'WatermelonLib-Unit-SnapshotTests'
snapshot_test_native_target.build_configurations.each do |bc|
bc.base_configuration_reference.real_path.basename.to_s.should == "WatermelonLib.unit-snapshottests.#{bc.name.downcase}.xcconfig"
bc.build_settings['PRODUCT_NAME'].should == 'WatermelonLib-Unit-SnapshotTests'
bc.build_settings['MACH_O_TYPE'].should.be.nil
bc.build_settings['PRODUCT_MODULE_NAME'].should.be.nil
bc.build_settings['CODE_SIGNING_REQUIRED'].should == 'YES'
bc.build_settings['CODE_SIGNING_ALLOWED'].should == 'YES'
bc.build_settings['CODE_SIGN_IDENTITY'].should == 'iPhone Developer'
bc.build_settings['INFOPLIST_FILE'].should == 'Target Support Files/WatermelonLib/WatermelonLib-Unit-SnapshotTests-Info.plist'
bc.build_settings['GCC_PREFIX_HEADER'].should == 'Target Support Files/WatermelonLib/WatermelonLib-Unit-SnapshotTests-prefix.pch'
end
snapshot_test_native_target.symbol_type.should == :unit_test_bundle
app_native_target = @project.targets[7]
app_native_target.name.should == 'WatermelonLib-App'
app_native_target.product_reference.name.should == 'WatermelonLib-App'
app_native_target.build_configurations.each do |bc|
bc.base_configuration_reference.real_path.basename.to_s.should == "WatermelonLib.app.#{bc.name.downcase}.xcconfig"
bc.build_settings['PRODUCT_NAME'].should == 'WatermelonLib-App'
bc.build_settings['PRODUCT_BUNDLE_IDENTIFIER'].should == 'org.cocoapods.${PRODUCT_NAME:rfc1034identifier}'
bc.build_settings['CURRENT_PROJECT_VERSION'].should == '1'
bc.build_settings['MACH_O_TYPE'].should.be.nil
bc.build_settings['PRODUCT_MODULE_NAME'].should.be.nil
bc.build_settings['CODE_SIGNING_REQUIRED'].should == 'YES'
bc.build_settings['CODE_SIGNING_ALLOWED'].should == 'YES'
bc.build_settings['CODE_SIGN_IDENTITY'].should == 'iPhone Developer'
bc.build_settings['CODE_SIGN_IDENTITY[sdk=appletvos*]'].should.be.nil
bc.build_settings['CODE_SIGN_IDENTITY[sdk=iphoneos*]'].should.be.nil
bc.build_settings['CODE_SIGN_IDENTITY[sdk=watchos*]'].should.be.nil
bc.build_settings['INFOPLIST_FILE'].should == 'App/WatermelonLib-App-Info.plist'
bc.build_settings['GCC_PREFIX_HEADER'].should == 'Target Support Files/WatermelonLib/WatermelonLib-App-prefix.pch'
end
app_native_target.symbol_type.should == :application
installation_result.test_native_targets.count.should == 3
installation_result.app_native_targets.count.should == 1
end
it 'adds the native test target to the project for OSX targets with correct build settings' do
@watermelon_spec.app_specs.each { |s| s.pod_target_xcconfig = {} }
installation_result = @osx_installer.install!
@project.targets.count.should == 9
@project.targets.first.name.should == 'WatermelonLib'
unit_test_native_target = @project.targets[1]
unit_test_native_target.name.should == 'WatermelonLib-Unit-Tests'
unit_test_native_target.product_reference.name.should == 'WatermelonLib-Unit-Tests'
unit_test_native_target.build_configurations.each do |bc|
bc.base_configuration_reference.real_path.basename.to_s.should == "WatermelonLib.unit-tests.#{bc.name.downcase}.xcconfig"
bc.build_settings['PRODUCT_NAME'].should == 'WatermelonLib-Unit-Tests'
bc.build_settings['MACH_O_TYPE'].should.be.nil
bc.build_settings['PRODUCT_MODULE_NAME'].should.be.nil
bc.build_settings['CODE_SIGNING_REQUIRED'].should.be.nil
bc.build_settings['CODE_SIGNING_ALLOWED'].should.be.nil
bc.build_settings['CODE_SIGN_IDENTITY'].should == ''
bc.build_settings['INFOPLIST_FILE'].should == 'Target Support Files/WatermelonLib/WatermelonLib-Unit-Tests-Info.plist'
bc.build_settings['GCC_PREFIX_HEADER'].should == 'Target Support Files/WatermelonLib/WatermelonLib-Unit-Tests-prefix.pch'
end
ui_test_native_target = @project.targets[2]
ui_test_native_target.name.should == 'WatermelonLib-UI-UITests'
ui_test_native_target.product_reference.name.should == 'WatermelonLib-UI-UITests'
ui_test_native_target.build_configurations.each do |bc|
bc.base_configuration_reference.real_path.basename.to_s.should == "WatermelonLib.ui-uitests.#{bc.name.downcase}.xcconfig"
bc.build_settings['PRODUCT_NAME'].should == 'WatermelonLib-UI-UITests'
bc.build_settings['MACH_O_TYPE'].should.be.nil
bc.build_settings['PRODUCT_MODULE_NAME'].should.be.nil
bc.build_settings['CODE_SIGNING_REQUIRED'].should.be.nil
bc.build_settings['CODE_SIGNING_ALLOWED'].should.be.nil
bc.build_settings['CODE_SIGN_IDENTITY'].should == ''
bc.build_settings['INFOPLIST_FILE'].should == 'Target Support Files/WatermelonLib/WatermelonLib-UI-UITests-Info.plist'
bc.build_settings['GCC_PREFIX_HEADER'].should == 'Target Support Files/WatermelonLib/WatermelonLib-UI-UITests-prefix.pch'
end
ui_test_native_target.symbol_type.should == :ui_test_bundle
snapshot_test_native_target = @project.targets[3]
snapshot_test_native_target.name.should == 'WatermelonLib-Unit-SnapshotTests'
snapshot_test_native_target.product_reference.name.should == 'WatermelonLib-Unit-SnapshotTests'
snapshot_test_native_target.build_configurations.each do |bc|
bc.base_configuration_reference.real_path.basename.to_s.should == "WatermelonLib.unit-snapshottests.#{bc.name.downcase}.xcconfig"
bc.build_settings['PRODUCT_NAME'].should == 'WatermelonLib-Unit-SnapshotTests'
bc.build_settings['MACH_O_TYPE'].should.be.nil
bc.build_settings['PRODUCT_MODULE_NAME'].should.be.nil
bc.build_settings['CODE_SIGNING_REQUIRED'].should.be.nil
bc.build_settings['CODE_SIGNING_ALLOWED'].should.be.nil
bc.build_settings['CODE_SIGN_IDENTITY'].should == ''
bc.build_settings['INFOPLIST_FILE'].should == 'Target Support Files/WatermelonLib/WatermelonLib-Unit-SnapshotTests-Info.plist'
bc.build_settings['GCC_PREFIX_HEADER'].should == 'Target Support Files/WatermelonLib/WatermelonLib-Unit-SnapshotTests-prefix.pch'
end
snapshot_test_native_target.symbol_type.should == :unit_test_bundle
app_native_target = @project.targets[7]
app_native_target.name.should == 'WatermelonLib-App'
app_native_target.product_reference.name.should == 'WatermelonLib-App'
app_native_target.build_configurations.each do |bc|
bc.base_configuration_reference.real_path.basename.to_s.should == "WatermelonLib.app.#{bc.name.downcase}.xcconfig"
bc.build_settings['PRODUCT_NAME'].should == 'WatermelonLib-App'
bc.build_settings['PRODUCT_BUNDLE_IDENTIFIER'].should == 'org.cocoapods.${PRODUCT_NAME:rfc1034identifier}'
bc.build_settings['CURRENT_PROJECT_VERSION'].should == '1'
bc.build_settings['CODE_SIGN_IDENTITY'].should == ''
bc.build_settings['MACH_O_TYPE'].should.be.nil
bc.build_settings['PRODUCT_MODULE_NAME'].should.be.nil
bc.build_settings['CODE_SIGN_IDENTITY'].should == ''
bc.build_settings['INFOPLIST_FILE'].should == 'App/WatermelonLib-App-Info.plist'
bc.build_settings['GCC_PREFIX_HEADER'].should == 'Target Support Files/WatermelonLib/WatermelonLib-App-prefix.pch'
end
app_native_target.symbol_type.should == :application
installation_result.test_native_targets.count.should == 3
installation_result.app_native_targets.count.should == 1
end
it 'raises when a test spec has no source files' do
@watermelon_ios_pod_target.test_spec_consumers.first.stubs(:source_files).returns([])
e = ->() { @ios_installer.install! }.should.raise Informative
e.message.should.
include 'Unable to install the `WatermelonLib` pod, because the `WatermelonLib-Unit-Tests` target in Xcode would have no sources to compile.'
end
it 'raises when an app spec has no source files' do
@watermelon_ios_pod_target.app_spec_consumers.first.stubs(:source_files).returns([])
e = ->() { @ios_installer.install! }.should.raise Informative
e.message.should.
include 'Unable to install the `WatermelonLib` pod, because the `WatermelonLib-App` target in Xcode would have no sources to compile.'
end
it 'adds swiftSwiftOnoneSupport ld flag to the debug configuration' do
@watermelon_ios_pod_target.stubs(:uses_swift?).returns(true)
@ios_installer.install!
test_native_target = @project.targets[1]
debug_configuration = test_native_target.build_configurations.find(&:debug?)
debug_configuration.build_settings['OTHER_LDFLAGS'].should == '$(inherited) -lswiftSwiftOnoneSupport'
release_configuration = test_native_target.build_configurations.find { |bc| bc.type == :release }
release_configuration.build_settings['OTHER_LDFLAGS'].should.be.nil
end
it 'adds files to build phases correctly depending on the native target' do
@ios_installer.install!
@project.targets.count.should == 9
native_target = @project.targets[0]
native_target.source_build_phase.files.count.should == 2
native_target.source_build_phase.files.map(&:display_name).sort.should == [
'Watermelon.m',
'WatermelonLib-dummy.m',
]
unit_test_native_target = @project.targets[1]
unit_test_native_target.source_build_phase.files.count.should == 2
unit_test_native_target.source_build_phase.files.map(&:display_name).sort.should == [
'WatermelonSwiftTests.swift',
'WatermelonTests.m',
]
ui_test_native_target = @project.targets[2]
ui_test_native_target.source_build_phase.files.count.should == 1
ui_test_native_target.source_build_phase.files.map(&:display_name).sort.should == [
'WatermelonUITests.m',
]
snapshot_test_native_target = @project.targets[3]
snapshot_test_native_target.source_build_phase.files.count.should == 1
snapshot_test_native_target.source_build_phase.files.map(&:display_name).sort.should == [
'WatermelonSnapshotTests.m',
]
app_native_target = @project.targets[7]
app_native_target.source_build_phase.files.count.should == 1
app_native_target.source_build_phase.files.map(&:display_name).sort.should == [
'main.swift',
]
end
it 'adds xcconfig file reference for test native targets' do
@ios_installer.install!
group = @project['Pods/WatermelonLib/Support Files']
group.children.map(&:display_name).sort.should.include 'WatermelonLib.unit-tests.debug.xcconfig'
group.children.map(&:display_name).sort.should.include 'WatermelonLib.unit-tests.release.xcconfig'
group.children.map(&:display_name).sort.should.include 'WatermelonLib.unit-snapshottests.debug.xcconfig'
group.children.map(&:display_name).sort.should.include 'WatermelonLib.unit-snapshottests.release.xcconfig'
end
it 'adds xcconfig file reference for app native targets' do
@ios_installer.install!
group = @project['Pods/WatermelonLib/Support Files']
group.children.map(&:display_name).sort.should.include 'WatermelonLib.app.debug.xcconfig'
group.children.map(&:display_name).sort.should.include 'WatermelonLib.app.release.xcconfig'
end
it 'does not add test header imports to umbrella header' do
@watermelon_ios_pod_target.stubs(:build_type).returns(BuildType.dynamic_framework)
@ios_installer.install!
content = @watermelon_ios_pod_target.umbrella_header_path.read
content.should.not =~ /"CoconutTestHeader.h"/
end
it 'uses header_dir to umbrella header imports' do
@watermelon_ios_pod_target.file_accessors.first.spec_consumer.stubs(:header_dir).returns('Watermelon')
@watermelon_ios_pod_target.stubs(:build_type).returns(BuildType.static_library)
@watermelon_ios_pod_target.stubs(:defines_module?).returns(true)
@ios_installer.install!
content = @watermelon_ios_pod_target.umbrella_header_path.read
content.should =~ %r{"Watermelon/Watermelon.h"}
end
it 'uses header_dir and header_mappings_dir to umbrella header imports' do
@watermelon_ios_pod_target.file_accessors.first.spec_consumer.stubs(:header_dir).returns('Watermelon2')
@watermelon_ios_pod_target.file_accessors.first.spec_consumer.stubs(:header_mappings_dir).returns('Classes')
@watermelon_ios_pod_target.stubs(:build_type).returns(BuildType.static_library)
@watermelon_ios_pod_target.stubs(:defines_module?).returns(true)
@ios_installer.install!
content = @watermelon_ios_pod_target.umbrella_header_path.read
content.should =~ %r{"Watermelon2/Watermelon.h"}
end
it 'does not use header_dir to umbrella header imports' do
@watermelon_ios_pod_target.file_accessors.first.spec_consumer.stubs(:header_dir).returns('Watermelon')
@watermelon_ios_pod_target.stubs(:build_type).returns(BuildType.dynamic_framework)
@watermelon_ios_pod_target.stubs(:defines_module?).returns(true)
@ios_installer.install!
content = @watermelon_ios_pod_target.umbrella_header_path.read
content.should.not =~ %r{"Watermelon/Watermelon.h"}
content.should =~ /"Watermelon.h"/
end
it 'adds test xcconfig file reference for test resource bundle targets' do
installation_result = @ios_installer.install!
installation_result.resource_bundle_targets.count.should == 0
installation_result.test_resource_bundle_targets.count.should == 3
unit_test_resource_bundle_target = @project.targets.find { |t| t.name == 'WatermelonLib-WatermelonLibTestResources' }
unit_test_resource_bundle_target.build_configurations.each do |bc|
bc.base_configuration_reference.real_path.basename.to_s.should == "WatermelonLib.unit-tests.#{bc.name.downcase}.xcconfig"
bc.build_settings['CONFIGURATION_BUILD_DIR'].should.be.nil
end
@project.targets.find { |t| t.name == 'WatermelonLib-WatermelonLibSnapshotTestResources' }.should.be.nil
end
it 'creates embed frameworks script for test target' do
@watermelon_ios_pod_target.stubs(:build_type => BuildType.dynamic_framework)
@ios_installer.install!
script_path = @watermelon_ios_pod_target.embed_frameworks_script_path_for_spec(@watermelon_ios_pod_target.test_specs.first)
script = script_path.read
@watermelon_ios_pod_target.user_build_configurations.keys.each do |configuration|
script.should.include <<-eos.strip_heredoc
if [[ "$CONFIGURATION" == "#{configuration}" ]]; then
install_framework "${BUILT_PRODUCTS_DIR}/WatermelonLib/WatermelonLib.framework"
fi
eos
end
end
it 'creates embed frameworks script for app target' do
@watermelon_ios_pod_target.stubs(:build_type => BuildType.dynamic_framework)
@ios_installer.install!
script_path = @watermelon_ios_pod_target.embed_frameworks_script_path_for_spec(@watermelon_ios_pod_target.app_specs.first)
script = script_path.read
@watermelon_ios_pod_target.user_build_configurations.keys.each do |configuration|
script.should.include <<-eos.strip_heredoc
if [[ "$CONFIGURATION" == "#{configuration}" ]]; then
install_framework "${BUILT_PRODUCTS_DIR}/WatermelonLib/WatermelonLib.framework"
fi
eos
end
end
it 'creates embed frameworks script for app target that includes framework paths from dependencies' do
@watermelon_ios_pod_target.dependent_targets = [@banana_target]
@watermelon_ios_pod_target.stubs(:framework_paths).returns('WatermelonLib' => [])
@watermelon_ios_pod_target.stubs(:build_type => BuildType.dynamic_framework)
@ios_installer.install!
script_path = @watermelon_ios_pod_target.embed_frameworks_script_path_for_spec(@watermelon_ios_pod_target.app_specs.first)
script = script_path.read
@watermelon_ios_pod_target.user_build_configurations.keys.each do |configuration|
script.should.include <<-eos.strip_heredoc
if [[ "$CONFIGURATION" == "#{configuration}" ]]; then
install_framework "${BUILT_PRODUCTS_DIR}/BananaLib/BananaLib.framework"
fi
eos
end
end
it 'creates and adds launch screen storyboard for app target' do
@watermelon_ios_pod_target.stubs(:build_type => BuildType.dynamic_framework)
@ios_installer.install!
app_target = @project.targets.find { |t| t.name == 'WatermelonLib-App' }
launch_screen = app_target.resources_build_phase.files_references.find { |fr| fr.name == 'LaunchScreen.storyboard' }
launch_screen.path.should.end_with 'Pods/WatermelonLib-App/LaunchScreen.storyboard'
launch_screen.real_path.should.be.file
end
it 'does not add launch screen storyboard for app target when it is a spec resource' do
@watermelon_ios_pod_target.stubs(:build_type => BuildType.dynamic_framework)
path = Pathname('/tmp/Resources/LaunchScreen.storyboard')
path.stubs(:realpath => path, :file? => true, :exist? => true)
fr = @watermelon_ios_pod_target.file_accessors.find do |fa|
fa.spec.name == 'WatermelonLib/App'
end
fr.stubs(:resources => fr.resources + [path])
@ios_installer.install!
app_target = @project.targets.find { |t| t.name == 'WatermelonLib-App' }
launch_screen = app_target.resources_build_phase.files_references.find { |f| f.name == 'LaunchScreen.storyboard' }
launch_screen.should.be.nil # since it was not installed by the file references installer in the before block
end
it 'adds the resources bundles to the copy resources script for test target' do
@ios_installer.install!
script_path = @watermelon_ios_pod_target.copy_resources_script_path_for_spec(@watermelon_spec.test_specs.first)
script = script_path.read
@watermelon_ios_pod_target.user_build_configurations.keys.each do |configuration|
script.should.include <<-eos.strip_heredoc
if [[ "$CONFIGURATION" == "#{configuration}" ]]; then
install_resource "${PODS_ROOT}/../../spec/fixtures/watermelon-lib/App/resource.txt"
install_resource "${PODS_CONFIGURATION_BUILD_DIR}/WatermelonLibTestResources.bundle"
fi
eos
end
end
it 'adds the resources to the copy resources phase for test target when a pod target is a static framework' do
@watermelon_ios_pod_target.stubs(:build_type => BuildType.static_framework)
@ios_installer.install!
unit_test_target = @project.targets.find { |t| t.name == 'WatermelonLib-Unit-Tests' }
resources = unit_test_target.resources_build_phase.files
resources.count.should > 0
resource = resources.find { |res| res.file_ref.path.include?('resource.txt') }
resource.should.be.not.nil
end
it 'adds the resources bundles to the copy resources script for app target' do
@ios_installer.install!
script_path = @watermelon_ios_pod_target.copy_resources_script_path_for_spec(@watermelon_spec.app_specs.first)
script = script_path.read
@watermelon_ios_pod_target.user_build_configurations.keys.each do |configuration|
script.should.include <<-eos.strip_heredoc
if [[ "$CONFIGURATION" == "#{configuration}" ]]; then
install_resource "${PODS_CONFIGURATION_BUILD_DIR}/WatermelonLib/WatermelonLibExampleAppResources.bundle"
fi
eos
end
end
it 'allows pod target xcconfigs to override values normally set directly on the target' do
@watermelon_ios_pod_target.root_spec.pod_target_xcconfig = { 'PRODUCT_MODULE_NAME' => 'FOOBAR' }
@watermelon_ios_pod_target.test_specs.each { |s| s.pod_target_xcconfig = { 'PRODUCT_NAME' => 'FOOBAR_TEST' } }
@ios_installer.install!
library_target = @project.targets.find { |t| t.name == 'WatermelonLib' }
library_target.build_configurations.map { |bc| bc.build_settings['PRODUCT_MODULE_NAME'] }.uniq.should == [nil]
library_target.resolved_build_setting('PRODUCT_MODULE_NAME', true).values.uniq.should == %w(FOOBAR)
unit_test_target = @project.targets.find { |t| t.name == 'WatermelonLib-Unit-Tests' }
unit_test_target.build_configurations.map { |bc| bc.build_settings['PRODUCT_NAME'] }.uniq.should == [nil]
unit_test_target.resolved_build_setting('PRODUCT_NAME', true).values.uniq.should == %w(FOOBAR_TEST)
test_resource_bundle_target = @project.targets.find { |t| t.name == 'WatermelonLib-WatermelonLibTestResources' }
test_resource_bundle_target.build_configurations.map { |bc| bc.build_settings['PRODUCT_NAME'] }.uniq.should == [nil]
test_resource_bundle_target.resolved_build_setting('PRODUCT_NAME', true).values.uniq.should == %w(FOOBAR_TEST)
test_resource_bundle_target = @project.targets.find { |t| t.name == 'WatermelonLib-WatermelonLibTestResources' }
test_resource_bundle_target.build_configurations.map { |bc| bc.build_settings['PRODUCT_NAME'] }.uniq.should == [nil]
test_resource_bundle_target.resolved_build_setting('PRODUCT_NAME', true).values.uniq.should == %w(FOOBAR_TEST)
app_target = @project.targets.find { |t| t.name == 'WatermelonLib-App' }
app_target.build_configurations.map { |bc| bc.build_settings['PRODUCT_NAME'] }.uniq.should == [nil]
app_target.resolved_build_setting('PRODUCT_NAME', true).values.uniq.should == %w(ExampleApp)
end
it 'should not crash with nil build settings' do
user_build_configurations = { 'MyConfig' => :myconfig }
@watermelon_ios_pod_target = fixture_pod_target_with_specs([@watermelon_spec], BuildType.static_library,
user_build_configurations, [],
Platform.new(:ios, '6.0'),
[@ios_target_definition])
@ios_installer = PodTargetInstaller.new(config.sandbox, @project, @watermelon_ios_pod_target)
@ios_installer.stubs(:create_xcconfig_file)
@watermelon_ios_pod_target.root_spec.pod_target_xcconfig = { 'PRODUCT_MODULE_NAME' => 'FOOBAR' }
@watermelon_ios_pod_target.build_settings[:release].should.nil?
@watermelon_ios_pod_target.build_settings[:debug].should.nil?
@ios_installer.install!
end
it 'adds swift compatibility header phase for swift static libraries' do
@watermelon_ios_pod_target.stubs(:build_type => BuildType.static_library, :uses_swift? => true)
@ios_installer.install!
native_target = @project.targets.find { |t| t.name == @watermelon_ios_pod_target.label }
compatibility_header_phase = native_target.build_phases.find { |ph| ph.display_name == 'Copy generated compatibility header' }
compatibility_header_phase.shell_script.should == <<-'SH'.strip_heredoc
COMPATIBILITY_HEADER_PATH="${BUILT_PRODUCTS_DIR}/Swift Compatibility Header/${PRODUCT_MODULE_NAME}-Swift.h"
MODULE_MAP_PATH="${BUILT_PRODUCTS_DIR}/${PRODUCT_MODULE_NAME}.modulemap"
ditto "${DERIVED_SOURCES_DIR}/${PRODUCT_MODULE_NAME}-Swift.h" "${COMPATIBILITY_HEADER_PATH}"
ditto "${PODS_ROOT}/Headers/Public/WatermelonLib/WatermelonLib.modulemap" "${MODULE_MAP_PATH}"
ditto "${PODS_ROOT}/Headers/Public/WatermelonLib/WatermelonLib-umbrella.h" "${BUILT_PRODUCTS_DIR}"
printf "\n\nmodule ${PRODUCT_MODULE_NAME}.Swift {\n header \"${COMPATIBILITY_HEADER_PATH}\"\n requires objc\n}\n" >> "${MODULE_MAP_PATH}"
SH
compatibility_header_phase.input_paths.should == %w(${DERIVED_SOURCES_DIR}/${PRODUCT_MODULE_NAME}-Swift.h ${PODS_ROOT}/Headers/Public/WatermelonLib/WatermelonLib.modulemap ${PODS_ROOT}/Headers/Public/WatermelonLib/WatermelonLib-umbrella.h)
compatibility_header_phase.output_paths.should == %w(${BUILT_PRODUCTS_DIR}/${PRODUCT_MODULE_NAME}.modulemap ${BUILT_PRODUCTS_DIR}/WatermelonLib-umbrella.h ${BUILT_PRODUCTS_DIR}/Swift\ Compatibility\ Header/${PRODUCT_MODULE_NAME}-Swift.h)
end
it 'does not add swift compatibility header phase for swift static frameworks' do
@watermelon_ios_pod_target.stubs(:build_type => BuildType.static_framework, :uses_swift? => true)
@ios_installer.install!
native_target = @project.targets.find { |t| t.name == @watermelon_ios_pod_target.label }
compatibility_header_phase = native_target.build_phases.find { |ph| ph.display_name == 'Copy generated compatibility header' }
compatibility_header_phase.should.be.nil
end
it 'raises for swift static libraries with custom module maps' do
@watermelon_ios_pod_target.stubs(:build_type => BuildType.static_library, :uses_swift? => true)
@ios_installer.stubs(:custom_module_map => mock('custom_module_map', :read => ''))
e = ->() { @ios_installer.install! }.should.raise(Informative)
e.message.should.include '[!] Using Swift static libraries with custom module maps is currently not supported. Please build `WatermelonLib` as a framework or remove the custom module map.'
end
end
describe 'test other files under sources' do
before do
@minions_spec = fixture_spec('minions-lib/MinionsLib.podspec')
@target_definition = fixture_target_definition('SampleProject')
@project = Project.new(config.sandbox.project_path)
@project.add_pod_group('MinionsLib', fixture('minions-lib'))
@minions_pod_target = fixture_pod_target_with_specs([@minions_spec, *@minions_spec.recursive_subspecs],
BuildType.static_library,
{ 'Debug' => :debug, 'Release' => :release }, [],
Platform.ios, [@target_definition])
FileReferencesInstaller.new(config.sandbox, [@minions_pod_target], @project).install!
@installer = PodTargetInstaller.new(config.sandbox, @project, @minions_pod_target)
end
it 'raises when references are missing for non-source files' do
@minions_pod_target.stubs(:build_type).returns(BuildType.dynamic_framework)
exception = lambda { @installer.install! }.should.raise Informative
exception.message.should.include 'Unable to find other source ref for `Contents.json` for target `MinionsLib`.'
end
end
#--------------------------------------#
it 'adds the source files of each pod to the target of the Pod library' do
names = @installer.install!.native_target.source_build_phase.files.map { |bf| bf.file_ref.display_name }
names.should.include('Banana.m')
end
describe 'deals with invalid source file references' do
before do
file_accessor = @pod_target.file_accessors.first
@first_header_file = file_accessor.source_files.find { |sf| sf.extname == '.h' }
@first_source_file = file_accessor.source_files.find { |sf| sf.extname == '.m' }
@header_symlink_file = @first_header_file.dirname + "SymLinkOf-#{@first_header_file.basename}"
@source_symlink_file = @first_source_file.dirname + "SymLinkOf-#{@first_source_file.basename}"
FileUtils.rm_f(@header_symlink_file.to_s)
FileUtils.rm_f(@source_symlink_file.to_s)
end
after do
FileUtils.rm_f(@header_symlink_file.to_s)
FileUtils.rm_f(@source_symlink_file.to_s)
end
it 'raises when source file reference is not found' do
file_path = @first_source_file.dirname + "notthere-#{@first_source_file.basename}"
File.symlink(file_path, @source_symlink_file)
path_list = Sandbox::PathList.new(fixture('banana-lib'))
file_accessor = Sandbox::FileAccessor.new(path_list, @banana_spec.consumer(:ios))
@pod_target.stubs(:file_accessors).returns([file_accessor])
exception = lambda { @installer.install! }.should.raise Informative
exception.message.should.include 'Unable to find source ref for `SymLinkOf-Banana.m` for target `BananaLib`.'
end
it 'raises when header file reference is not found' do
file_path = @first_header_file.dirname + "notthere-#{@first_header_file.basename}"
File.symlink(file_path, @header_symlink_file)
path_list = Sandbox::PathList.new(fixture('banana-lib'))
file_accessor = Sandbox::FileAccessor.new(path_list, @banana_spec.consumer(:ios))
@pod_target.stubs(:file_accessors).returns([file_accessor])
exception = lambda { @installer.install! }.should.raise Informative
exception.message.should.include 'Unable to find header ref for `SymLinkOf-Banana.h` for target `BananaLib`.'
end
it 'does not raise when header file reference is found' do
File.symlink(@first_header_file, @header_symlink_file)
path_list = Sandbox::PathList.new(fixture('banana-lib'))
file_accessor = Sandbox::FileAccessor.new(path_list, @banana_spec.consumer(:ios))
@pod_target.stubs(:file_accessors).returns([file_accessor])
group = @project.group_for_spec('BananaLib')
@project.add_file_reference(@header_symlink_file.to_s, group)
lambda { @installer.install! }.should.not.raise
end
it 'does not raise when source file reference is found' do
File.symlink(@first_source_file, @source_symlink_file)
path_list = Sandbox::PathList.new(fixture('banana-lib'))
file_accessor = Sandbox::FileAccessor.new(path_list, @banana_spec.consumer(:ios))
@pod_target.stubs(:file_accessors).returns([file_accessor])
group = @project.group_for_spec('BananaLib')
@project.add_file_reference(@source_symlink_file.to_s, group)
lambda { @installer.install! }.should.not.raise
end
end
#--------------------------------------#
it 'adds framework resources to the framework target' do
@pod_target.stubs(:build_type => BuildType.dynamic_framework)
@installer.install!
resources = @project.targets.first.resources_build_phase.files
resources.count.should > 0
resource = resources.find { |res| res.file_ref.path.include?('logo-sidebar.png') }
resource.should.be.not.nil
resource = resources.find { |res| res.file_ref.path.include?('en.lproj') }
resource.should.be.not.nil
end
it 'adds compilable framework resources to the static framework target' do
@pod_target.stubs(:build_type => BuildType.static_framework)
@installer.install!
resources = @project.targets.first.resources_build_phase.files
resources.count.should > 0
resource = resources.find { |res| res.file_ref.path.include?('Migration.xcmappingmodel') }
resource.should.be.not.nil
end
it 'doesn\'t add non-compilable framework resources to the static framework target' do
@pod_target.stubs(:build_type => BuildType.static_framework)
@installer.install!
resources = @project.targets.first.resources_build_phase.files
resources.count.should > 0
resource = resources.find { |res| res.file_ref.path.include?('logo-sidebar.png') }
resource.should.be.nil
resource = resources.find { |res| res.file_ref.path.include?('en.lproj') }
resource.should.be.nil
end
it 'doesn\'t add xcassets resources to the static framework target' do
@pod_target.stubs(:build_type => BuildType.static_framework)
@installer.install!
resources = @project.targets.first.resources_build_phase.files
resources.count.should > 0
resource = resources.find { |res| res.file_ref.path.include?('Images.xcassets') }
resource.should.be.nil
end
it 'adds xcassets resources to the dynamic framework target' do
@pod_target.stubs(:build_type => BuildType.dynamic_framework)
@installer.install!
resources = @project.targets.first.resources_build_phase.files
resources.count.should > 0
resource = resources.find { |res| res.file_ref.path.include?('Images.xcassets') }
resource.should.be.not.nil
end
it 'includes spec info_plist entries for dynamic frameworks' do
@pod_target.stubs(:build_type => BuildType.dynamic_framework)
expected_entries = {
'SOME_VAR' => 'SOME_VALUE',
}
@banana_spec.info_plist = expected_entries
@installer.expects(:create_info_plist_file_with_sandbox).
with do |sandbox, _, _, version, platform, bundle_type, other_args|
sandbox.should == config.sandbox
version.should == '1.0.0'
platform.should == :ios
bundle_type.should == :fmwk
other_args[:additional_entries].should == expected_entries
end
@installer.install!
end
it 'includes spec info_plist entries for static frameworks' do
@pod_target.stubs(:build_type => BuildType.static_framework)
expected_entries = {
'SOME_VAR' => 'SOME_VALUE',
}
@banana_spec.info_plist = expected_entries
@installer.expects(:create_info_plist_file_with_sandbox).
with do |sandbox, _, _, version, platform, bundle_type, other_args|
sandbox.should == config.sandbox
version.should == '1.0.0'
platform.should == :ios
bundle_type.should == :fmwk
other_args[:additional_entries].should == expected_entries
end
@installer.install!
end
#--------------------------------------#
describe 'with a scoped pod target' do
before do
@pod_target = @pod_target.scoped.first
@installer = PodTargetInstaller.new(config.sandbox, @project, @pod_target)
end
it 'adds file references for the support files of the target' do
@installer.install!
group = @project['Pods/BananaLib/Support Files']
group.children.map(&:display_name).sort.should == [
'BananaLib-Pods-SampleProject-dummy.m',
'BananaLib-Pods-SampleProject-prefix.pch',
'BananaLib-Pods-SampleProject.debug.xcconfig',
'BananaLib-Pods-SampleProject.release.xcconfig',
]
end
it 'verifies keeping prefix header generation' do
@pod_target.specs.first.stubs(:prefix_header_file).returns(true)
@installer.install!
group = @project['Pods/BananaLib/Support Files']
group.children.map(&:display_name).sort.should == [
'BananaLib-Pods-SampleProject-dummy.m',
'BananaLib-Pods-SampleProject-prefix.pch',
'BananaLib-Pods-SampleProject.debug.xcconfig',
'BananaLib-Pods-SampleProject.release.xcconfig',
]
end
it 'verifies disabling prefix header generation' do
@pod_target.specs.first.stubs(:prefix_header_file).returns(false)
@installer.install!
group = @project['Pods/BananaLib/Support Files']
group.children.map(&:display_name).sort.should == [
'BananaLib-Pods-SampleProject-dummy.m',
'BananaLib-Pods-SampleProject.debug.xcconfig',
'BananaLib-Pods-SampleProject.release.xcconfig',
]
end
it 'verifies keeping prefix header generation for subspecs' do
@project = Project.new(config.sandbox.project_path)
@project.add_pod_group('HeadersMappingSubspec', fixture('HeadersMappingSubspec'))
@pod_spec = fixture_spec('HeadersMappingSubspec/HeadersMappingSubspec.podspec')
@pod_target = fixture_pod_target_with_specs([@pod_spec, *@pod_spec.subspecs], BuildType.dynamic_framework,
{ 'Debug' => :debug, 'Release' => :release }, [],
Pod::Platform.new(:ios, '6.0'), [@target_definition], nil)
FileReferencesInstaller.new(config.sandbox, [@pod_target], @project).install!
@installer = PodTargetInstaller.new(config.sandbox, @project, @pod_target)
@installer.install!
group = @project['Pods/HeadersMappingSubspec/Support Files']
group.children.map(&:display_name).sort.should == [
'HeadersMappingSubspec-Info.plist',
'HeadersMappingSubspec-dummy.m',
'HeadersMappingSubspec-prefix.pch',
'HeadersMappingSubspec.debug.xcconfig',
'HeadersMappingSubspec.modulemap',
'HeadersMappingSubspec.release.xcconfig',
]
end
it 'verifies skipping prefix header generation for subspecs' do
@project = Project.new(config.sandbox.project_path)
@project.add_pod_group('HeadersMappingSubspec', fixture('HeadersMappingSubspec'))
@pod_spec = fixture_spec('HeadersMappingSubspec/HeadersMappingSubspec.podspec')
@pod_target = fixture_pod_target_with_specs([@pod_spec, *@pod_spec.subspecs], BuildType.dynamic_framework,
{ 'Debug' => :debug, 'Release' => :release }, [],
Pod::Platform.new(:ios, '6.0'), [@target_definition], nil)
@pod_spec.stubs(:prefix_header_file).returns(false)
FileReferencesInstaller.new(config.sandbox, [@pod_target], @project).install!
@installer = PodTargetInstaller.new(config.sandbox, @project, @pod_target)
@installer.install!
group = @project['Pods/HeadersMappingSubspec/Support Files']
group.children.map(&:display_name).sort.should == [
'HeadersMappingSubspec-Info.plist',
'HeadersMappingSubspec-dummy.m',
'HeadersMappingSubspec.debug.xcconfig',
'HeadersMappingSubspec.modulemap',
'HeadersMappingSubspec.release.xcconfig',
]
end
it 'adds the module map when the target defines a module' do
@pod_target.stubs(:defines_module?).returns(true)
@installer.install!
group = @project['Pods/BananaLib/Support Files']
group.children.map(&:display_name).sort.should == [
'BananaLib-Pods-SampleProject-dummy.m',
'BananaLib-Pods-SampleProject-prefix.pch',
'BananaLib-Pods-SampleProject.debug.xcconfig',
'BananaLib-Pods-SampleProject.modulemap',
'BananaLib-Pods-SampleProject.release.xcconfig',
]
end
it 'adds the target for the static library to the project' do
@installer.install!
@project.targets.count.should == 1
@project.targets.first.name.should == 'BananaLib-Pods-SampleProject'
end
describe 'resource bundle targets' do
before do
@banana_spec.resource_bundles = { 'banana_bundle' => ['Resources/**/*'] }
end
it 'adds the resource bundle targets' do
@installer.install!
@bundle_target = @project.targets.find { |t| t.name == 'BananaLib-Pods-SampleProject-banana_bundle' }
@bundle_target.should.be.an.instance_of Xcodeproj::Project::Object::PBXNativeTarget
@bundle_target.product_reference.name.should == 'banana_bundle.bundle'
@bundle_target.product_reference.path.should == 'BananaLib-Pods-SampleProject-banana_bundle.bundle'
@bundle_target.platform_name.should == :ios
@bundle_target.deployment_target.should == '4.3'
end
it 'adds the build configurations to the resources bundle targets' do
@installer.install!
@bundle_target = @project.targets.find { |t| t.name == 'BananaLib-Pods-SampleProject-banana_bundle' }
@bundle_target.build_configurations.each do |bc|
file = config.sandbox.root + @pod_target.xcconfig_path(bc.name.downcase)
bc.base_configuration_reference.real_path.should == file
end
end
it 'sets the correct product name' do
@installer.install!
@bundle_target = @project.targets.find { |t| t.name == 'BananaLib-Pods-SampleProject-banana_bundle' }
@bundle_target.build_configurations.each do |bc|
bc.build_settings['PRODUCT_NAME'].should == 'banana_bundle'
end
end
it 'sets the correct Info.plist file path' do
@installer.install!
@bundle_target = @project.targets.find { |t| t.name == 'BananaLib-Pods-SampleProject-banana_bundle' }
@bundle_target.build_configurations.each do |bc|
bc.build_settings['INFOPLIST_FILE'].should == 'Target Support Files/BananaLib-Pods-SampleProject/ResourceBundle-banana_bundle-BananaLib-Pods-SampleProject-Info.plist'
end
end
it 'sets the correct build dir' do
@installer.install!
@bundle_target = @project.targets.find { |t| t.name == 'BananaLib-Pods-SampleProject-banana_bundle' }
@bundle_target.build_configurations.each do |bc|
bc.build_settings['CONFIGURATION_BUILD_DIR'].should == '$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/BananaLib-Pods-SampleProject'
end
end
it 'sets the correct targeted device family for the resource bundle targets' do
@installer.install!
@bundle_target = @project.targets.find { |t| t.name == 'BananaLib-Pods-SampleProject-banana_bundle' }
@bundle_target.build_configurations.each do |bc|
bc.build_settings['TARGETED_DEVICE_FAMILY'].should == '1,2'
end
end
it 'sets the correct default module for storyboards in resource bundle targets' do
@installer.install!
@bundle_target = @project.targets.find { |t| t.name == 'BananaLib-Pods-SampleProject-banana_bundle' }
@bundle_target.build_configurations.each do |bc|
bc.build_settings['IBSC_MODULE'].should == 'BananaLib'
end
end
it 'sets the Swift version build setting when resources bundle contains sources and target has Swift' do
@banana_spec.resource_bundles = { 'banana_bundle' => ['Resources/**/*'] }
@banana_spec.module_map = nil
@pod_target.stubs(:uses_swift?).returns(true)
@pod_target.stubs(:uses_swift_for_spec?).returns(true)
@pod_target.stubs(:swift_version).returns('3.2')
@installer.install!
@bundle_target = @project.targets.find { |t| t.name == 'BananaLib-Pods-SampleProject-banana_bundle' }