@@ -683,19 +683,24 @@ private final class ProjectModelItemClass: ProjectModelItem {
683
683
#expect( fileGroup. children. count == 2 )
684
684
685
685
// Examine its children
686
- if let fileRef = try ? #require ( fileGroup. children. first as? FileReference ) {
686
+ if let fileRef = 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 " )
692
694
}
693
- if let fileRef = try ? #require( fileGroup. children [ 1 ] as? FileReference ) {
695
+
696
+ if let fileRef = fileGroup. children [ 1 ] as? FileReference {
694
697
#expect( fileRef. guid == " second-fileReference-guid " )
695
698
#expect( fileRef. sourceTree == SourceTree . groupRelative)
696
699
#expect( fileRef. path. stringRep == " ClassOne.h " )
697
700
#expect( fileRef. fileTypeIdentifier == " sourcecode.c.h " )
698
701
#expect( fileRef. regionVariantName == nil )
702
+ } else {
703
+ Issue . record ( " Missing file reference in group " )
699
704
}
700
705
}
701
706
@@ -740,19 +745,24 @@ private final class ProjectModelItemClass: ProjectModelItem {
740
745
#expect( versionGroup. children. count == 2 )
741
746
742
747
// Examine its children
743
- if let fileRef = try ? #require ( versionGroup. children [ 0 ] as? FileReference ) {
748
+ if let fileRef = versionGroup. children [ 0 ] as? FileReference {
744
749
#expect( fileRef. guid == " first-versionedFile-guid " )
745
750
#expect( fileRef. sourceTree == SourceTree . groupRelative)
746
751
#expect( fileRef. path. stringRep == " CoreData-1.xcdatamodel " )
747
752
#expect( fileRef. fileTypeIdentifier == " wrapper.xcdatamodel " )
748
753
#expect( fileRef. regionVariantName == nil )
754
+ } else {
755
+ Issue . record ( " Missing file reference in group " )
749
756
}
750
- if let fileRef = try ? #require( versionGroup. children [ 1 ] as? FileReference ) {
757
+
758
+ if let fileRef = versionGroup. children [ 1 ] as? FileReference {
751
759
#expect( fileRef. guid == " second-versionedFile-guid " )
752
760
#expect( fileRef. sourceTree == SourceTree . groupRelative)
753
761
#expect( fileRef. path. stringRep == " CoreData-2.xcdatamodel " )
754
762
#expect( fileRef. fileTypeIdentifier == " wrapper.xcdatamodel " )
755
763
#expect( fileRef. regionVariantName == nil )
764
+ } else {
765
+ Issue . record ( " Missing file reference in group " )
756
766
}
757
767
}
758
768
@@ -821,26 +831,34 @@ private final class ProjectModelItemClass: ProjectModelItem {
821
831
#expect( variantGroup. name == " Thingy.xib " )
822
832
823
833
// Examine its children, the xib and its localized strings files
824
- if let fileRef = try ? #require ( variantGroup. children [ 0 ] as? FileReference ) {
834
+ if let fileRef = variantGroup. children [ 0 ] as? FileReference {
825
835
#expect( fileRef. guid == " xib-fileReference-guid " )
826
836
#expect( fileRef. sourceTree == SourceTree . groupRelative)
827
837
#expect( fileRef. path. stringRep == " Thingy.xib " )
828
838
#expect( fileRef. fileTypeIdentifier == " file.xib " )
829
839
#expect( fileRef. regionVariantName == nil )
840
+ } else {
841
+ Issue . record ( " Missing file reference in group " )
830
842
}
831
- if let fileRef = try ? #require( variantGroup. children [ 1 ] as? FileReference ) {
843
+
844
+ if let fileRef = variantGroup. children [ 1 ] as? FileReference {
832
845
#expect( fileRef. guid == " fr-strings-fileReference-guid " )
833
846
#expect( fileRef. sourceTree == SourceTree . groupRelative)
834
847
#expect( fileRef. path. stringRep == " Thingy.strings " )
835
848
#expect( fileRef. fileTypeIdentifier == " text.plist.strings " )
836
849
#expect( fileRef. regionVariantName == " fr " )
850
+ } else {
851
+ Issue . record ( " Missing file reference in group " )
837
852
}
838
- if let fileRef = try ? #require( variantGroup. children [ 2 ] as? FileReference ) {
853
+
854
+ if let fileRef = variantGroup. children [ 2 ] as? FileReference {
839
855
#expect( fileRef. guid == " de-strings-fileReference-guid " )
840
856
#expect( fileRef. sourceTree == SourceTree . groupRelative)
841
857
#expect( fileRef. path. stringRep == " Thingy.strings " )
842
858
#expect( fileRef. fileTypeIdentifier == " text.plist.strings " )
843
859
#expect( fileRef. regionVariantName == " de " )
860
+ } else {
861
+ Issue . record ( " Missing file reference in group " )
844
862
}
845
863
}
846
864
@@ -941,10 +959,14 @@ private final class ProjectModelItemClass: ProjectModelItem {
941
959
]
942
960
943
961
// Convert the test data into a property list, then read the build phase from it.
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
- }
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
+ } )
948
970
}
949
971
950
972
// A headers build phase
@@ -962,10 +984,14 @@ private final class ProjectModelItemClass: ProjectModelItem {
962
984
]
963
985
964
986
// Convert the test data into a property list, then read the build phase from it.
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
- }
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
+ } )
969
995
}
970
996
971
997
// A resources build phase
@@ -983,10 +1009,14 @@ private final class ProjectModelItemClass: ProjectModelItem {
983
1009
]
984
1010
985
1011
// Convert the test data into a property list, then read the build phase from it.
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
- }
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
+ } )
990
1020
}
991
1021
992
1022
// A copy files build phase
@@ -1007,13 +1037,17 @@ private final class ProjectModelItemClass: ProjectModelItem {
1007
1037
]
1008
1038
1009
1039
// Convert the test data into a property list, then read the build phase from it.
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
- }
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
+ } )
1017
1051
}
1018
1052
1019
1053
// A shell script build phase
@@ -1036,20 +1070,24 @@ private final class ProjectModelItemClass: ProjectModelItem {
1036
1070
]
1037
1071
1038
1072
// Convert the test data into a property list, then read the build phase from it.
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
- }
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
+ } )
1053
1091
}
1054
1092
}
1055
1093
@@ -1352,7 +1390,8 @@ private final class ProjectModelItemClass: ProjectModelItem {
1352
1390
1353
1391
// 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.
1354
1392
func checkBuildFileRef( of buildPhase: BuildPhaseWithBuildFiles , fileRef: FileReference ) throws {
1355
- guard let buildFileRef = try ? #require( buildPhase. buildFiles. first) else {
1393
+ guard let buildFileRef = buildPhase. buildFiles. first else {
1394
+ Issue . record ( " No build file in build phase " )
1356
1395
return
1357
1396
}
1358
1397
guard case let . reference( buildFileRefGuid) = buildFileRef. buildableItem else {
@@ -1726,4 +1765,3 @@ private final class ProjectModelItemClass: ProjectModelItem {
1726
1765
] )
1727
1766
}
1728
1767
}
1729
-
0 commit comments