Skip to content

deprecate validation that a resource localization exists in the default language #4172

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions Sources/PackageLoading/Diagnostics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -127,17 +127,6 @@ extension Basics.Diagnostic {
localized variants will never be chosen
""")
}

static func missingDefaultLocalizationResource(
resource: String,
targetName: String,
defaultLocalization: String
) -> Self {
.warning("""
resource '\(resource)' in target '\(targetName)' is missing the default localization \
'\(defaultLocalization)'; the default localization is used as a fallback when no other localization matches
""")
}
}

extension ObservabilityMetadata {
Expand Down
19 changes: 0 additions & 19 deletions Sources/PackageLoading/TargetSourcesBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ public struct TargetSourcesBuilder {
diagnoseConflictingResources(in: resources)
diagnoseCopyConflictsWithLocalizationDirectories(in: resources)
diagnoseLocalizedAndUnlocalizedVariants(in: resources)
diagnoseMissingDevelopmentRegionResource(in: resources)
diagnoseInfoPlistConflicts(in: resources)
diagnoseInvalidResource(in: target.resources)

Expand Down Expand Up @@ -322,24 +321,6 @@ public struct TargetSourcesBuilder {
}
}

private func diagnoseMissingDevelopmentRegionResource(in resources: [Resource]) {
// We can't diagnose anything here without a default localization set.
guard let defaultLocalization = self.defaultLocalization else {
return
}

let localizedResources = resources.lazy.filter({ $0.localization != nil && $0.localization != "Base" })
let resourcesByBasename = Dictionary(grouping: localizedResources, by: { $0.path.basename })
for (basename, resources) in resourcesByBasename {
if !resources.contains(where: { $0.localization == defaultLocalization }) {
self.observabilityScope.emit(.missingDefaultLocalizationResource(
resource: basename,
targetName: target.name,
defaultLocalization: defaultLocalization))
}
}
}

private func diagnoseInfoPlistConflicts(in resources: [Resource]) {
for resource in resources {
if resource.destination == RelativePath("Info.plist") {
Expand Down
Loading