Bugfix: Consider folders with dot in it when generating projects (#826)

* Bug fix in SourceGenerator

Folders which would have a dot in it, would be added to Copy Bundle Resources even though it contained swift files. This commit, updates the if checks to check if the extension is not of type lproj or xcassets or bundle. This would let Xcodegen handle paths with dots in it

* Refactor SourceGenerator.swift getGroupSources function

* Add FolderWithDot2.0 to TestProject/App_iOS

* Update TestProject fixture with SwiftFileInDotPath and FolderWithDot2.0 changes

* Update test to assert bundles are included in resources

* Remove intentDefinition from whitelistedDirectoryExtensions because it's not a directory, it's always a file so the check is not required
This commit is contained in:
Asif
2020-04-09 18:17:54 +05:30
committed by GitHub
parent b1edbda583
commit 400c19ee9a
5 changed files with 35 additions and 2 deletions
+1
View File
@@ -8,6 +8,7 @@
#### Fixed
- Fixed issue when linking and embeding static frameworks: they should be linked and NOT embed. [#820](https://github.com/yonaskolb/XcodeGen/pull/820) @acecilia
- Fixed issue when generating projects for paths with a dot in the folder for swift sources. [#826](https://github.com/yonaskolb/XcodeGen/pull/826) @asifmohd
## 2.15.1
+4 -2
View File
@@ -413,12 +413,14 @@ class SourceGenerator {
let children = try getSourceChildren(targetSource: targetSource, dirPath: path, excludePaths: excludePaths, includePaths: includePaths)
let createIntermediateGroups = targetSource.createIntermediateGroups ?? project.options.createIntermediateGroups
let directoryExtensionsToSkip = ["lproj", "bundle", "xcassets", "xcdatamodeld"]
let directories = children
.filter { $0.isDirectory && $0.extension == nil && $0.extension != "lproj" }
.filter { $0.isDirectory && !directoryExtensionsToSkip.contains($0.extension ?? "") }
let whitelistedDirectoryExtensionsForFilePath = ["xcdatamodeld", "xcdatamodel" , "xcassets"]
let filePaths = children
.filter { $0.isFile || $0.extension != nil && $0.extension != "lproj" }
.filter { $0.isFile || $0.extension != nil && $0.extension != "lproj" && (whitelistedDirectoryExtensionsForFilePath.contains($0.extension ?? "") || !$0.isDirectory) }
let localisedDirectories = children
.filter { $0.extension == "lproj" }
@@ -0,0 +1,7 @@
import Foundation
extension String {
func printHelloWorld() {
print("Hello World!")
}
}
@@ -88,6 +88,7 @@
7F658343A505B824321E086B /* Headers in Headers */ = {isa = PBXBuildFile; fileRef = 2E1E747C7BC434ADB80CC269 /* Headers */; settings = {ATTRIBUTES = (Public, ); }; };
803B7CE086CFBA409F9D1ED7 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 108BB29172D27BE3BD1E7F35 /* Assets.xcassets */; };
818D448D4DDD6649B5B26098 /* example.mp4 in Resources */ = {isa = PBXBuildFile; fileRef = 28360ECA4D727FAA58557A81 /* example.mp4 */; settings = {ASSET_TAGS = (tag1, tag2, ); }; };
87927928A8A3460166ACB819 /* SwiftFileInDotPath.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F430AABE04B7499B458D9DB /* SwiftFileInDotPath.swift */; settings = {COMPILER_FLAGS = "-Werror"; }; };
900CFAD929CAEE3861127627 /* MyBundle.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 7B5068D64404C61A67A18458 /* MyBundle.bundle */; };
95DD9941E1529FD2AE1A191D /* StaticLibrary_ObjC.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 5A2B916A11DCC2565241359F /* StaticLibrary_ObjC.h */; };
96B55C0F660235FE6BDD8869 /* MyFramework.h in Headers */ = {isa = PBXBuildFile; fileRef = 6A58A16491CDDF968B0D56DE /* MyFramework.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -488,6 +489,7 @@
28360ECA4D727FAA58557A81 /* example.mp4 */ = {isa = PBXFileReference; path = example.mp4; sourceTree = "<group>"; };
2A5F527F2590C14956518174 /* FrameworkFile.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FrameworkFile.swift; sourceTree = "<group>"; };
2E1E747C7BC434ADB80CC269 /* Headers */ = {isa = PBXFileReference; lastKnownFileType = folder; path = Headers; sourceTree = SOURCE_ROOT; };
2F430AABE04B7499B458D9DB /* SwiftFileInDotPath.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftFileInDotPath.swift; sourceTree = "<group>"; };
33F6DCDC37D2E66543D4965D /* App_macOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = App_macOS.app; sourceTree = BUILT_PRODUCTS_DIR; };
34F13B632328979093CE6056 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
3571E41E19A5AB8AAAB04109 /* StandaloneAssets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = StandaloneAssets.xcassets; sourceTree = "<group>"; };
@@ -688,6 +690,7 @@
1F2DE413CF2CB54988158172 /* App */ = {
isa = PBXGroup;
children = (
2F80635127D17ECB7748067B /* FolderWithDot2.0 */,
F0D48A913C087D049C8EDDD7 /* App.entitlements */,
7F1A2F579A6F79C62DDA0571 /* AppDelegate.swift */,
3797E591F302ECC0AA2FC607 /* Assets.xcassets */,
@@ -762,6 +765,14 @@
path = Module;
sourceTree = "<group>";
};
2F80635127D17ECB7748067B /* FolderWithDot2.0 */ = {
isa = PBXGroup;
children = (
2F430AABE04B7499B458D9DB /* SwiftFileInDotPath.swift */,
);
path = FolderWithDot2.0;
sourceTree = "<group>";
};
3F2E22B7AB20FA42CD205C2A /* CopyFiles */ = {
isa = PBXGroup;
children = (
@@ -2025,6 +2036,7 @@
F788A3FA1CE6489BC257C1C3 /* Model.xcdatamodeld in Sources */,
58C18019E71E372F635A3FB4 /* MoreUnder.swift in Sources */,
5D10822B0E7C33DD6979F656 /* Standalone.swift in Sources */,
87927928A8A3460166ACB819 /* SwiftFileInDotPath.swift in Sources */,
2730C6D0A35AED4ADD6EDF17 /* ViewController.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
@@ -62,6 +62,8 @@ class SourceGeneratorTests: XCTestCase {
- a.swift
- B:
- b.swift
- C2.0:
- c.swift
"""
try createDirectories(directories)
@@ -71,6 +73,7 @@ class SourceGeneratorTests: XCTestCase {
let pbxProj = try project.generatePbxProj()
try pbxProj.expectFile(paths: ["Sources", "A", "a.swift"], buildPhase: .sources)
try pbxProj.expectFile(paths: ["Sources", "A", "B", "b.swift"], buildPhase: .sources)
try pbxProj.expectFile(paths: ["Sources", "A", "C2.0", "c.swift"], buildPhase: .sources)
}
$0.it("supports frameworks in sources") {
@@ -400,13 +403,19 @@ class SourceGeneratorTests: XCTestCase {
- B:
- b.swift
- c.jpg
- D2.0:
- d.swift
- E.bundle:
- e.json
"""
try createDirectories(directories)
let target = Target(name: "Test", type: .application, platform: .iOS, sources: [
"Sources/A/a.swift",
"Sources/A/B/b.swift",
"Sources/A/D2.0/d.swift",
"Sources/A/Assets.xcassets",
"Sources/A/E.bundle/e.json",
"Sources/A/B/c.jpg",
])
let project = Project(basePath: directoryPath, name: "Test", targets: [target])
@@ -414,8 +423,10 @@ class SourceGeneratorTests: XCTestCase {
let pbxProj = try project.generatePbxProj()
try pbxProj.expectFile(paths: ["Sources/A", "a.swift"], names: ["A", "a.swift"], buildPhase: .sources)
try pbxProj.expectFile(paths: ["Sources/A/B", "b.swift"], names: ["B", "b.swift"], buildPhase: .sources)
try pbxProj.expectFile(paths: ["Sources/A/D2.0", "d.swift"], names: ["D2.0", "d.swift"], buildPhase: .sources)
try pbxProj.expectFile(paths: ["Sources/A/B", "c.jpg"], names: ["B", "c.jpg"], buildPhase: .resources)
try pbxProj.expectFile(paths: ["Sources/A", "Assets.xcassets"], names: ["A", "Assets.xcassets"], buildPhase: .resources)
try pbxProj.expectFile(paths: ["Sources/A/E.bundle", "e.json"], names: ["E.bundle", "e.json"], buildPhase: .resources)
}
$0.it("generates shared sources") {