mirror of
https://github.com/yonaskolb/XcodeGen.git
synced 2024-12-11 07:16:40 +03:00
Merge branch 'master' into project-path
This commit is contained in:
commit
62a26b0a17
@ -10,6 +10,7 @@
|
||||
- Fixed macOS unit test setting preset [#665](https://github.com/yonaskolb/XcodeGen/pull/665) @yonaskolb
|
||||
- Add `rcproject` files to sources build phase instead of resources [#669](https://github.com/yonaskolb/XcodeGen/pull/669) @Qusic
|
||||
- Prefer default configuration names for generated schemes [#673](https://github.com/yonaskolb/XcodeGen/pull/673) @giginet
|
||||
- Fixed some resource files being placed to "Recovered References" group [#679](https://github.com/yonaskolb/XcodeGen/pull/679) @nivanchikov
|
||||
- Fixed resolving relative paths with custom project destination [#681](https://github.com/yonaskolb/XcodeGen/pull/681) @giginet
|
||||
|
||||
#### Internal
|
||||
|
@ -270,7 +270,7 @@ class SourceGenerator {
|
||||
for child in children {
|
||||
// only add the children that aren't already in the cachedGroup
|
||||
// Check equality by path and sourceTree because XcodeProj.PBXObject.== is very slow.
|
||||
if !cachedGroupChildren.contains(where: { $0.path == child.path && $0.sourceTree == child.sourceTree }) {
|
||||
if !cachedGroupChildren.contains(where: { $0.name == child.name && $0.path == child.path && $0.sourceTree == child.sourceTree }) {
|
||||
cachedGroupChildren.append(child)
|
||||
}
|
||||
}
|
||||
|
@ -167,6 +167,69 @@ class SourceGeneratorTests: XCTestCase {
|
||||
try expect(variableGroup.children.filter { $0 == refs.first }.count) == 1
|
||||
}
|
||||
}
|
||||
|
||||
$0.it("handles localized resources") {
|
||||
let directories = """
|
||||
App:
|
||||
Resources:
|
||||
en-CA.lproj:
|
||||
- empty.json
|
||||
- Localizable.strings
|
||||
en-US.lproj:
|
||||
- empty.json
|
||||
- Localizable.strings
|
||||
en.lproj:
|
||||
- empty.json
|
||||
- Localizable.strings
|
||||
fonts:
|
||||
SFUI:
|
||||
- SFUILight.ttf
|
||||
"""
|
||||
try createDirectories(directories)
|
||||
|
||||
let target = Target(name: "Test", type: .application, platform: .iOS, sources: [TargetSource(path: "App/Resources")])
|
||||
|
||||
let options = SpecOptions(createIntermediateGroups: true)
|
||||
let project = Project(basePath: directoryPath, name: "Test", targets: [target], options: options)
|
||||
|
||||
let outputXcodeProj = try project.generateXcodeProject()
|
||||
try outputXcodeProj.write(path: directoryPath)
|
||||
|
||||
let inputXcodeProj = try XcodeProj(path: directoryPath)
|
||||
let pbxProj = inputXcodeProj.pbxproj
|
||||
|
||||
func getFileReferences(_ path: String) -> [PBXFileReference] {
|
||||
return pbxProj.fileReferences.filter { $0.path == path }
|
||||
}
|
||||
|
||||
func getVariableGroups(_ name: String?) -> [PBXVariantGroup] {
|
||||
return pbxProj.variantGroups.filter { $0.name == name }
|
||||
}
|
||||
|
||||
let stringsResourceName = "Localizable.strings"
|
||||
let jsonResourceName = "empty.json"
|
||||
|
||||
guard let stringsVariableGroup = getVariableGroups(stringsResourceName).first else { throw failure("Couldn't find the variable group") }
|
||||
|
||||
guard let jsonVariableGroup = getVariableGroups(jsonResourceName).first else { throw failure("Couldn't find the variable group") }
|
||||
|
||||
let stringsResource = "en.lproj/Localizable.strings"
|
||||
let jsonResource = "en-CA.lproj/empty.json"
|
||||
|
||||
do {
|
||||
let refs = getFileReferences(stringsResource)
|
||||
try expect(refs.count) == 1
|
||||
try expect(refs.first!.uuid.hasPrefix("TEMP")) == false
|
||||
try expect(stringsVariableGroup.children.filter { $0 == refs.first }.count) == 1
|
||||
}
|
||||
|
||||
do {
|
||||
let refs = getFileReferences(jsonResource)
|
||||
try expect(refs.count) == 1
|
||||
try expect(refs.first!.uuid.hasPrefix("TEMP")) == false
|
||||
try expect(jsonVariableGroup.children.filter { $0 == refs.first }.count) == 1
|
||||
}
|
||||
}
|
||||
|
||||
$0.it("handles duplicate names") {
|
||||
let directories = """
|
||||
|
Loading…
Reference in New Issue
Block a user