@@ -174,10 +174,10 @@ public struct TargetSourcesBuilder {
174
174
let ignored = pathToRule. filter { $0. value == . ignored } . map { $0. key }
175
175
let others = pathToRule. filter { $0. value == . none } . map { $0. key }
176
176
177
- diagnoseConflictingResources ( in: resources)
177
+ try diagnoseConflictingResources ( in: resources)
178
178
diagnoseCopyConflictsWithLocalizationDirectories ( in: resources)
179
179
diagnoseLocalizedAndUnlocalizedVariants ( in: resources)
180
- diagnoseInfoPlistConflicts ( in: resources)
180
+ try diagnoseInfoPlistConflicts ( in: resources)
181
181
diagnoseInvalidResource ( in: target. resources)
182
182
183
183
// It's an error to contain mixed language source files.
@@ -309,10 +309,10 @@ public struct TargetSourcesBuilder {
309
309
return Self . resource ( for: path, with: rule, defaultLocalization: defaultLocalization, targetName: target. name, targetPath: targetPath, observabilityScope: observabilityScope)
310
310
}
311
311
312
- private func diagnoseConflictingResources( in resources: [ Resource ] ) {
313
- let duplicateResources = resources. spm_findDuplicateElements ( by: \. destination )
312
+ private func diagnoseConflictingResources( in resources: [ Resource ] ) throws {
313
+ let duplicateResources = resources. spm_findDuplicateElements ( by: \. destinationForGrouping )
314
314
for resources in duplicateResources {
315
- self . observabilityScope. emit ( . conflictingResource( path: resources [ 0 ] . destination, targetName: target. name) )
315
+ try self . observabilityScope. emit ( . conflictingResource( path: resources [ 0 ] . destination, targetName: target. name) )
316
316
317
317
for resource in resources {
318
318
let relativePath = resource. path. relative ( to: targetPath)
@@ -346,9 +346,9 @@ public struct TargetSourcesBuilder {
346
346
}
347
347
}
348
348
349
- private func diagnoseInfoPlistConflicts( in resources: [ Resource ] ) {
349
+ private func diagnoseInfoPlistConflicts( in resources: [ Resource ] ) throws {
350
350
for resource in resources {
351
- if try ! resource. destination == RelativePath ( validating: " Info.plist " ) /* try! safe */ {
351
+ if try resource. destination == RelativePath ( validating: " Info.plist " ) {
352
352
self . observabilityScope. emit ( . infoPlistResourceConflict(
353
353
path: resource. path. relative ( to: targetPath) ,
354
354
targetName: target. name) )
@@ -770,3 +770,13 @@ extension PackageReference.Kind {
770
770
}
771
771
}
772
772
}
773
+
774
+ extension PackageModel . Resource {
775
+ fileprivate var destinationForGrouping : RelativePath ? {
776
+ do {
777
+ return try self . destination
778
+ } catch {
779
+ return . none
780
+ }
781
+ }
782
+ }
0 commit comments