Skip to content

Commit 511ffb3

Browse files
authored
deprecate validation that a resource localization exists for the default language (#4172)
motivation: the validation / warning is redundant changes: * remove the validation for the default language * adjust test * refactor TargetSourcesBuilderTests so we can test for no diagnostics rdar://86297221
1 parent 34dfe48 commit 511ffb3

File tree

3 files changed

+140
-150
lines changed

3 files changed

+140
-150
lines changed

Sources/PackageLoading/Diagnostics.swift

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -127,17 +127,6 @@ extension Basics.Diagnostic {
127127
localized variants will never be chosen
128128
""")
129129
}
130-
131-
static func missingDefaultLocalizationResource(
132-
resource: String,
133-
targetName: String,
134-
defaultLocalization: String
135-
) -> Self {
136-
.warning("""
137-
resource '\(resource)' in target '\(targetName)' is missing the default localization \
138-
'\(defaultLocalization)'; the default localization is used as a fallback when no other localization matches
139-
""")
140-
}
141130
}
142131

143132
extension ObservabilityMetadata {

Sources/PackageLoading/TargetSourcesBuilder.swift

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ public struct TargetSourcesBuilder {
172172
diagnoseConflictingResources(in: resources)
173173
diagnoseCopyConflictsWithLocalizationDirectories(in: resources)
174174
diagnoseLocalizedAndUnlocalizedVariants(in: resources)
175-
diagnoseMissingDevelopmentRegionResource(in: resources)
176175
diagnoseInfoPlistConflicts(in: resources)
177176
diagnoseInvalidResource(in: target.resources)
178177

@@ -322,24 +321,6 @@ public struct TargetSourcesBuilder {
322321
}
323322
}
324323

325-
private func diagnoseMissingDevelopmentRegionResource(in resources: [Resource]) {
326-
// We can't diagnose anything here without a default localization set.
327-
guard let defaultLocalization = self.defaultLocalization else {
328-
return
329-
}
330-
331-
let localizedResources = resources.lazy.filter({ $0.localization != nil && $0.localization != "Base" })
332-
let resourcesByBasename = Dictionary(grouping: localizedResources, by: { $0.path.basename })
333-
for (basename, resources) in resourcesByBasename {
334-
if !resources.contains(where: { $0.localization == defaultLocalization }) {
335-
self.observabilityScope.emit(.missingDefaultLocalizationResource(
336-
resource: basename,
337-
targetName: target.name,
338-
defaultLocalization: defaultLocalization))
339-
}
340-
}
341-
}
342-
343324
private func diagnoseInfoPlistConflicts(in resources: [Resource]) {
344325
for resource in resources {
345326
if resource.destination == RelativePath("Info.plist") {

0 commit comments

Comments
 (0)