@@ -683,24 +683,19 @@ private final class ProjectModelItemClass: ProjectModelItem {
683
683
#expect( fileGroup. children. count == 2 )
684
684
685
685
// Examine its children
686
- if let fileRef = fileGroup. children. first as? FileReference {
686
+ if let fileRef = try ? #require ( fileGroup. children. first as? FileReference ? ) {
687
687
#expect( fileRef. guid == " first-fileReference-guid " )
688
688
#expect( fileRef. sourceTree == SourceTree . groupRelative)
689
689
#expect( fileRef. path. stringRep == " ClassOne.m " )
690
690
#expect( fileRef. fileTypeIdentifier == " sourcecode.c.objc " )
691
691
#expect( fileRef. regionVariantName == nil )
692
- } else {
693
- Issue . record ( " Missing file reference in group " )
694
692
}
695
-
696
- if let fileRef = fileGroup. children [ 1 ] as? FileReference {
693
+ if let fileRef = try ? #require( fileGroup. children [ 1 ] as? FileReference ? ) {
697
694
#expect( fileRef. guid == " second-fileReference-guid " )
698
695
#expect( fileRef. sourceTree == SourceTree . groupRelative)
699
696
#expect( fileRef. path. stringRep == " ClassOne.h " )
700
697
#expect( fileRef. fileTypeIdentifier == " sourcecode.c.h " )
701
698
#expect( fileRef. regionVariantName == nil )
702
- } else {
703
- Issue . record ( " Missing file reference in group " )
704
699
}
705
700
}
706
701
@@ -745,24 +740,19 @@ private final class ProjectModelItemClass: ProjectModelItem {
745
740
#expect( versionGroup. children. count == 2 )
746
741
747
742
// Examine its children
748
- if let fileRef = versionGroup. children [ 0 ] as? FileReference {
743
+ if let fileRef = try ? #require ( versionGroup. children [ 0 ] as? FileReference ? ) {
749
744
#expect( fileRef. guid == " first-versionedFile-guid " )
750
745
#expect( fileRef. sourceTree == SourceTree . groupRelative)
751
746
#expect( fileRef. path. stringRep == " CoreData-1.xcdatamodel " )
752
747
#expect( fileRef. fileTypeIdentifier == " wrapper.xcdatamodel " )
753
748
#expect( fileRef. regionVariantName == nil )
754
- } else {
755
- Issue . record ( " Missing file reference in group " )
756
749
}
757
-
758
- if let fileRef = versionGroup. children [ 1 ] as? FileReference {
750
+ if let fileRef = try ? #require( versionGroup. children [ 1 ] as? FileReference ? ) {
759
751
#expect( fileRef. guid == " second-versionedFile-guid " )
760
752
#expect( fileRef. sourceTree == SourceTree . groupRelative)
761
753
#expect( fileRef. path. stringRep == " CoreData-2.xcdatamodel " )
762
754
#expect( fileRef. fileTypeIdentifier == " wrapper.xcdatamodel " )
763
755
#expect( fileRef. regionVariantName == nil )
764
- } else {
765
- Issue . record ( " Missing file reference in group " )
766
756
}
767
757
}
768
758
@@ -831,34 +821,26 @@ private final class ProjectModelItemClass: ProjectModelItem {
831
821
#expect( variantGroup. name == " Thingy.xib " )
832
822
833
823
// Examine its children, the xib and its localized strings files
834
- if let fileRef = variantGroup. children [ 0 ] as? FileReference {
824
+ if let fileRef = try ? #require ( variantGroup. children [ 0 ] as? FileReference ? ) {
835
825
#expect( fileRef. guid == " xib-fileReference-guid " )
836
826
#expect( fileRef. sourceTree == SourceTree . groupRelative)
837
827
#expect( fileRef. path. stringRep == " Thingy.xib " )
838
828
#expect( fileRef. fileTypeIdentifier == " file.xib " )
839
829
#expect( fileRef. regionVariantName == nil )
840
- } else {
841
- Issue . record ( " Missing file reference in group " )
842
830
}
843
-
844
- if let fileRef = variantGroup. children [ 1 ] as? FileReference {
831
+ if let fileRef = try ? #require( variantGroup. children [ 1 ] as? FileReference ? ) {
845
832
#expect( fileRef. guid == " fr-strings-fileReference-guid " )
846
833
#expect( fileRef. sourceTree == SourceTree . groupRelative)
847
834
#expect( fileRef. path. stringRep == " Thingy.strings " )
848
835
#expect( fileRef. fileTypeIdentifier == " text.plist.strings " )
849
836
#expect( fileRef. regionVariantName == " fr " )
850
- } else {
851
- Issue . record ( " Missing file reference in group " )
852
837
}
853
-
854
- if let fileRef = variantGroup. children [ 2 ] as? FileReference {
838
+ if let fileRef = try ? #require( variantGroup. children [ 2 ] as? FileReference ? ) {
855
839
#expect( fileRef. guid == " de-strings-fileReference-guid " )
856
840
#expect( fileRef. sourceTree == SourceTree . groupRelative)
857
841
#expect( fileRef. path. stringRep == " Thingy.strings " )
858
842
#expect( fileRef. fileTypeIdentifier == " text.plist.strings " )
859
843
#expect( fileRef. regionVariantName == " de " )
860
- } else {
861
- Issue . record ( " Missing file reference in group " )
862
844
}
863
845
}
864
846
@@ -959,14 +941,10 @@ private final class ProjectModelItemClass: ProjectModelItem {
959
941
]
960
942
961
943
// Convert the test data into a property list, then read the build phase from it.
962
- #expect( throws: Never . self, performing: {
963
- if let buildPhase = try BuildPhase . parsePIFDictAsBuildPhase ( buildPhasePIF, pifLoader: pifLoader) as? SourcesBuildPhase {
964
- // Examine the build phase.
965
- #expect( buildPhase. buildFiles. count == 1 )
966
- } else {
967
- Issue . record ( " Unexpected build phase type " )
968
- }
969
- } )
944
+ if let buildPhase = try ? #require( BuildPhase . parsePIFDictAsBuildPhase ( buildPhasePIF, pifLoader: pifLoader) as? SourcesBuildPhase ? ) {
945
+ // Examine the build phase.
946
+ #expect( buildPhase. buildFiles. count == 1 )
947
+ }
970
948
}
971
949
972
950
// A headers build phase
@@ -984,14 +962,10 @@ private final class ProjectModelItemClass: ProjectModelItem {
984
962
]
985
963
986
964
// Convert the test data into a property list, then read the build phase from it.
987
- #expect( throws: Never . self, performing: {
988
- if let buildPhase = try BuildPhase . parsePIFDictAsBuildPhase ( buildPhasePIF, pifLoader: pifLoader) as? HeadersBuildPhase {
989
- // Examine the build phase.
990
- #expect( buildPhase. buildFiles. count == 1 )
991
- } else {
992
- Issue . record ( " Unexpected build phase type " )
993
- }
994
- } )
965
+ if let buildPhase = try ? #require( BuildPhase . parsePIFDictAsBuildPhase ( buildPhasePIF, pifLoader: pifLoader) as? HeadersBuildPhase ? ) {
966
+ // Examine the build phase.
967
+ #expect( buildPhase. buildFiles. count == 1 )
968
+ }
995
969
}
996
970
997
971
// A resources build phase
@@ -1009,14 +983,10 @@ private final class ProjectModelItemClass: ProjectModelItem {
1009
983
]
1010
984
1011
985
// Convert the test data into a property list, then read the build phase from it.
1012
- #expect( throws: Never . self, performing: {
1013
- if let buildPhase = try BuildPhase . parsePIFDictAsBuildPhase ( buildPhasePIF, pifLoader: pifLoader) as? ResourcesBuildPhase {
1014
- // Examine the build phase.
1015
- #expect( buildPhase. buildFiles. count == 1 )
1016
- } else {
1017
- Issue . record ( " Unexpected build phase type " )
1018
- }
1019
- } )
986
+ if let buildPhase = try ? #require( BuildPhase . parsePIFDictAsBuildPhase ( buildPhasePIF, pifLoader: pifLoader) as? ResourcesBuildPhase ? ) {
987
+ // Examine the build phase.
988
+ #expect( buildPhase. buildFiles. count == 1 )
989
+ }
1020
990
}
1021
991
1022
992
// A copy files build phase
@@ -1037,17 +1007,13 @@ private final class ProjectModelItemClass: ProjectModelItem {
1037
1007
]
1038
1008
1039
1009
// Convert the test data into a property list, then read the build phase from it.
1040
- #expect( throws: Never . self, performing: {
1041
- if let buildPhase = try BuildPhase . parsePIFDictAsBuildPhase ( buildPhasePIF, pifLoader: pifLoader) as? CopyFilesBuildPhase {
1042
- // Examine the build phase.
1043
- #expect( buildPhase. destinationSubfolder. stringRep == " Resources " )
1044
- #expect( buildPhase. destinationSubpath. stringRep == " Subpath " )
1045
- #expect( buildPhase. buildFiles. count == 1 )
1046
- #expect( buildPhase. runOnlyForDeploymentPostprocessing) ;
1047
- } else {
1048
- Issue . record ( " Unexpected build phase type " )
1049
- }
1050
- } )
1010
+ if let buildPhase = try ? #require( BuildPhase . parsePIFDictAsBuildPhase ( buildPhasePIF, pifLoader: pifLoader) as? CopyFilesBuildPhase ? ) {
1011
+ // Examine the build phase.
1012
+ #expect( buildPhase. destinationSubfolder. stringRep == " Resources " )
1013
+ #expect( buildPhase. destinationSubpath. stringRep == " Subpath " )
1014
+ #expect( buildPhase. buildFiles. count == 1 )
1015
+ #expect( buildPhase. runOnlyForDeploymentPostprocessing) ;
1016
+ }
1051
1017
}
1052
1018
1053
1019
// A shell script build phase
@@ -1070,24 +1036,20 @@ private final class ProjectModelItemClass: ProjectModelItem {
1070
1036
]
1071
1037
1072
1038
// Convert the test data into a property list, then read the build phase from it.
1073
- #expect( throws: Never . self, performing: {
1074
- if let buildPhase = try BuildPhase . parsePIFDictAsBuildPhase ( buildPhasePIF, pifLoader: pifLoader) as? ShellScriptBuildPhase {
1075
- // Examine the build phase.
1076
- #expect( buildPhase. guid == " some-shellScriptBuildPhase-guid " )
1077
- #expect( buildPhase. name == " A Shell Script Phase " )
1078
- #expect( buildPhase. shellPath. stringRep == " /bin/sh " )
1079
- #expect( buildPhase. scriptContents == " echo \" Nothing to do. \" \n exit 0 " )
1080
- #expect( buildPhase. originalObjectID == " 1234512345 " )
1081
- #expect( buildPhase. inputFilePaths. count == 1 )
1082
- #expect( buildPhase. inputFilePaths. first? . stringRep == " /tmp/foo.in " )
1083
- #expect( buildPhase. outputFilePaths. count == 1 )
1084
- #expect( buildPhase. outputFilePaths. first? . stringRep == " /tmp/foo.out " )
1085
- #expect( buildPhase. emitEnvironment) ;
1086
- #expect( buildPhase. runOnlyForDeploymentPostprocessing) ;
1087
- } else {
1088
- Issue . record ( " Unexpected build phase type " )
1089
- }
1090
- } )
1039
+ if let buildPhase = try ? #require( BuildPhase . parsePIFDictAsBuildPhase ( buildPhasePIF, pifLoader: pifLoader) as? ShellScriptBuildPhase ? ) {
1040
+ // Examine the build phase.
1041
+ #expect( buildPhase. guid == " some-shellScriptBuildPhase-guid " )
1042
+ #expect( buildPhase. name == " A Shell Script Phase " )
1043
+ #expect( buildPhase. shellPath. stringRep == " /bin/sh " )
1044
+ #expect( buildPhase. scriptContents == " echo \" Nothing to do. \" \n exit 0 " )
1045
+ #expect( buildPhase. originalObjectID == " 1234512345 " )
1046
+ #expect( buildPhase. inputFilePaths. count == 1 )
1047
+ #expect( buildPhase. inputFilePaths. first? . stringRep == " /tmp/foo.in " )
1048
+ #expect( buildPhase. outputFilePaths. count == 1 )
1049
+ #expect( buildPhase. outputFilePaths. first? . stringRep == " /tmp/foo.out " )
1050
+ #expect( buildPhase. emitEnvironment) ;
1051
+ #expect( buildPhase. runOnlyForDeploymentPostprocessing) ;
1052
+ }
1091
1053
}
1092
1054
}
1093
1055
@@ -1391,8 +1353,7 @@ private final class ProjectModelItemClass: ProjectModelItem {
1391
1353
1392
1354
// Because of the way reference resolution of a BuildFile.BuildableItem works, we don't have a context to resolve the build file's references to real references, so all we can do is check that the GUID is what we expect.
1393
1355
func checkBuildFileRef( of buildPhase: BuildPhaseWithBuildFiles , fileRef: FileReference ) throws {
1394
- guard let buildFileRef = buildPhase. buildFiles. first else {
1395
- Issue . record ( " No build file in build phase " )
1356
+ guard let buildFileRef = try ? #require( buildPhase. buildFiles. first) else {
1396
1357
return
1397
1358
}
1398
1359
guard case let . reference( buildFileRefGuid) = buildFileRef. buildableItem else {
0 commit comments