Skip to content
Open
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
7 changes: 7 additions & 0 deletions Sources/XcodeGenKit/PBXProjGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1491,6 +1491,13 @@ public class PBXProjGenerator {
var exceptions: Set<String> = Set(
sourceGenerator.syncedFolderExceptions(for: targetSource, at: syncedPath)
.compactMap { try? $0.relativePath(from: syncedPath).string }
.map { rel in
// Xcode only honors localized exclusions in the variant-group form; per-language paths are ignored.
var parts = rel.split(separator: "/")
guard let i = parts.firstIndex(where: { $0.hasSuffix(".lproj") }) else { return rel }
parts.remove(at: i)
return "/Localized: \(parts.joined(separator: "/"))"
}
)

for infoPlistPath in Set(infoPlistFiles.values) {
Expand Down
33 changes: 33 additions & 0 deletions Tests/XcodeGenKitTests/SourceGeneratorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,39 @@ class SourceGeneratorTests: XCTestCase {
try expect(exceptions.contains("a.swift")) == false
}

$0.it("excludes localized files from synced folders using the variant-group form") {
let directories = """
Sources:
- a.swift
- b.swift
- Resources:
- en.lproj:
- Localizable.strings
- AppShortcuts.strings
- fr.lproj:
- Localizable.strings
- AppShortcuts.strings
"""
try createDirectories(directories)

let source = TargetSource(path: "Sources", includes: ["a.swift", "Resources/*.lproj/Localizable.strings"], type: .syncedFolder)
let target = Target(name: "Test", type: .application, platform: .iOS, sources: [source])
let project = Project(basePath: directoryPath, name: "Test", targets: [target])

let pbxProj = try project.generatePbxProj()
let syncedFolders = try pbxProj.getMainGroup().children.compactMap { $0 as? PBXFileSystemSynchronizedRootGroup }
let syncedFolder = try unwrap(syncedFolders.first)

let exceptionSet = try unwrap(syncedFolder.exceptions?.first as? PBXFileSystemSynchronizedBuildFileExceptionSet)
let exceptions = try unwrap(exceptionSet.membershipExceptions)

try expect(exceptions.contains("/Localized: Resources/AppShortcuts.strings")) == true
try expect(exceptions.contains("Resources/en.lproj/AppShortcuts.strings")) == false
try expect(exceptions.contains("Resources/fr.lproj/AppShortcuts.strings")) == false
try expect(exceptions.contains("/Localized: Resources/Localizable.strings")) == false
try expect(exceptions.contains("b.swift")) == true
}

$0.it("adds membership exceptions for nested synced folder with intermediate groups") {
let directories = """
Sources:
Expand Down