@@ -53,12 +53,21 @@ module Xcodeproj
53
53
@ios_application_tests = Xcodeproj ::Project ::PBXNativeTarget . new ( nil , 'E525241E16245AB20012E2BA' )
54
54
@ios_application_tests . name = "iOS applicationTests"
55
55
@ios_application_tests . product_type = "com.apple.product-type.bundle"
56
+ @ios_static_library = Xcodeproj ::Project ::PBXNativeTarget . new ( nil , '806F6FC217EFAF47001051EE' )
57
+ @ios_static_library . name = "iOS staticLibrary"
58
+ @ios_static_library . product_type = "com.apple.product-type.library.static"
59
+ @ios_static_library_tests = Xcodeproj ::Project ::PBXNativeTarget . new ( nil , '806F6FC217EFAF47001051EE' )
60
+ @ios_static_library_tests . name = "iOS staticLibraryTests"
61
+ @ios_static_library_tests . product_type = "com.apple.product-type.bundle"
56
62
end
57
63
58
64
describe 'For iOS Application' do
59
65
60
66
before do
61
- @scheme = Xcodeproj ::XCScheme . new ( 'Cocoa Application' , @ios_application , @ios_application_tests )
67
+ @scheme = Xcodeproj ::XCScheme . new
68
+ @scheme . add_build_target ( @ios_application , 'Cocoa Application' )
69
+ @scheme . add_test_target ( @ios_application_tests , 'Cocoa Application' )
70
+ @scheme . set_launch_target ( @ios_application , 'Cocoa Application' )
62
71
@xml = REXML ::Document . new File . new fixture_path ( 'Sample Project/Cocoa Application.xcodeproj/xcshareddata/xcschemes/iOS application.xcscheme' )
63
72
end
64
73
@@ -219,7 +228,8 @@ module Xcodeproj
219
228
describe 'For iOS Application Tests' do
220
229
221
230
before do
222
- @scheme = Xcodeproj ::XCScheme . new 'Cocoa Application' , @ios_application_tests , @ios_application_tests
231
+ @scheme = Xcodeproj ::XCScheme . new
232
+ @scheme . add_test_target ( @ios_application_tests , 'Cocoa Application' )
223
233
@xml = REXML ::Document . new File . new fixture_path ( 'Sample Project/Cocoa Application.xcodeproj/xcshareddata/xcschemes/iOS applicationTests.xcscheme' )
224
234
end
225
235
@@ -302,10 +312,9 @@ module Xcodeproj
302
312
extend SpecHelper ::TemporaryDirectory
303
313
304
314
before do
305
- @scheme = Xcodeproj ::XCScheme . new 'Cocoa Application' , @ios_application_tests , @ios_application_tests
306
- @scheme . build_target_for_running? . should . be . false
307
- @scheme . build_target_for_running = true
308
- @scheme . build_target_for_running? . should . be . true
315
+ @scheme = Xcodeproj ::XCScheme . new
316
+ @scheme . add_build_target ( @ios_application_tests , 'Cocoa Application' )
317
+ @scheme . add_test_target ( @ios_application_tests , 'Cocoa Application' )
309
318
@xml = REXML ::Document . new File . new fixture_path ( 'Sample Project/Cocoa Application.xcodeproj/xcshareddata/xcschemes/iOS applicationTests Set Build Target For Running.xcscheme' )
310
319
end
311
320
@@ -380,13 +389,113 @@ module Xcodeproj
380
389
end
381
390
382
391
it 'Save as Shared Scheme' do
383
- result = @scheme . save_as ( temporary_directory , true )
392
+ result = @scheme . save_as ( temporary_directory , 'iOS applicationTests' , true )
384
393
( result > 0 ) . should . be . true
385
394
File . exists? ( File . join temporary_directory , 'xcshareddata' , 'xcschemes' , 'iOS applicationTests.xcscheme' ) . should . be . true
386
395
end
387
396
388
397
it 'Save as User Scheme' do
389
- result = @scheme . save_as ( temporary_directory , false )
398
+ result = @scheme . save_as ( temporary_directory , 'iOS applicationTests' , false )
399
+ ( result > 0 ) . should . be . true
400
+ File . exists? ( File . join temporary_directory , 'xcuserdata' , "#{ ENV [ 'USER' ] } .xcuserdatad" , 'xcschemes' , 'iOS applicationTests.xcscheme' ) . should . be . true
401
+ end
402
+
403
+ end
404
+
405
+ #-------------------------------------------------------------------------#
406
+
407
+ describe 'For iOS Application And Static Library' do
408
+
409
+ extend SpecHelper ::TemporaryDirectory
410
+
411
+ before do
412
+ @scheme = Xcodeproj ::XCScheme . new
413
+ @scheme . add_build_target ( @ios_application , 'Cocoa Application' )
414
+ @scheme . add_build_target ( @ios_static_library , 'Cocoa Application' )
415
+ @scheme . add_test_target ( @ios_application_tests , 'Cocoa Application' )
416
+ @scheme . add_test_target ( @ios_static_library_tests , 'Cocoa Application' )
417
+ @scheme . set_launch_target ( @ios_application , 'Cocoa Application' )
418
+ @xml = REXML ::Document . new File . new fixture_path ( 'Sample Project/Cocoa Application.xcodeproj/xcshareddata/xcschemes/iOS application and static library.xcscheme' )
419
+ end
420
+
421
+ it 'XML Decl' do
422
+ @xml . xml_decl . should . be . equal @scheme . doc . xml_decl
423
+ end
424
+
425
+ it 'Scheme' do
426
+ compare_elements @xml . root , @scheme . doc . root
427
+ end
428
+
429
+ it 'Scheme > BuildAction' do
430
+ compare_elements @xml . root . elements [ 'BuildAction' ] , @scheme . doc . root . elements [ 'BuildAction' ]
431
+ end
432
+
433
+ it 'Scheme > TestAction' do
434
+ compare_elements @xml . root . elements [ 'TestAction' ] , @scheme . doc . root . elements [ 'TestAction' ]
435
+ end
436
+
437
+ it 'Scheme > TestAction > Testables' do
438
+ compare_elements \
439
+ @xml . root . elements [ 'TestAction' ] \
440
+ . elements [ 'Testables' ] , \
441
+ @scheme . doc . root . elements [ 'TestAction' ] \
442
+ . elements [ 'Testables' ]
443
+ end
444
+
445
+ it 'Scheme > TestAction > Testables > TestableReference' do
446
+ compare_elements \
447
+ @xml . root . elements [ 'TestAction' ] \
448
+ . elements [ 'Testables' ] \
449
+ . elements [ 'TestableReference' ] , \
450
+ @scheme . doc . root . elements [ 'TestAction' ] \
451
+ . elements [ 'Testables' ] \
452
+ . elements [ 'TestableReference' ]
453
+ end
454
+
455
+ it 'Scheme > TestAction > Testables > TestableReference > BuildableReference' do
456
+ compare_elements \
457
+ @xml . root . elements [ 'TestAction' ] \
458
+ . elements [ 'Testables' ] \
459
+ . elements [ 'TestableReference' ] \
460
+ . elements [ 'BuildableReference' ] , \
461
+ @scheme . doc . root . elements [ 'TestAction' ] \
462
+ . elements [ 'Testables' ] \
463
+ . elements [ 'TestableReference' ] \
464
+ . elements [ 'BuildableReference' ]
465
+ end
466
+
467
+ it 'Scheme > LaunchAction' do
468
+ compare_elements @xml . root . elements [ 'LaunchAction' ] , @scheme . doc . root . elements [ 'LaunchAction' ]
469
+ end
470
+
471
+ it 'Scheme > LaunchAction > AdditionalOptions' do
472
+ compare_elements \
473
+ @xml . root . elements [ 'LaunchAction' ] \
474
+ . elements [ 'AdditionalOptions' ] , \
475
+ @scheme . doc . root . elements [ 'LaunchAction' ] \
476
+ . elements [ 'AdditionalOptions' ]
477
+ end
478
+
479
+ it 'Scheme > ProfileAction' do
480
+ compare_elements @xml . root . elements [ 'ProfileAction' ] , @scheme . doc . root . elements [ 'ProfileAction' ]
481
+ end
482
+
483
+ it 'Scheme > AnalyzeAction' do
484
+ compare_elements @xml . root . elements [ 'AnalyzeAction' ] , @scheme . doc . root . elements [ 'AnalyzeAction' ]
485
+ end
486
+
487
+ it 'Scheme > ArchiveAction' do
488
+ compare_elements @xml . root . elements [ 'ArchiveAction' ] , @scheme . doc . root . elements [ 'ArchiveAction' ]
489
+ end
490
+
491
+ it 'Save as Shared Scheme' do
492
+ result = @scheme . save_as ( temporary_directory , 'iOS applicationTests' , true )
493
+ ( result > 0 ) . should . be . true
494
+ File . exists? ( File . join temporary_directory , 'xcshareddata' , 'xcschemes' , 'iOS applicationTests.xcscheme' ) . should . be . true
495
+ end
496
+
497
+ it 'Save as User Scheme' do
498
+ result = @scheme . save_as ( temporary_directory , 'iOS applicationTests' , false )
390
499
( result > 0 ) . should . be . true
391
500
File . exists? ( File . join temporary_directory , 'xcuserdata' , "#{ ENV [ 'USER' ] } .xcuserdatad" , 'xcschemes' , 'iOS applicationTests.xcscheme' ) . should . be . true
392
501
end
0 commit comments