From ff3bfd6955905b9f5fc9cf58b9f52906a38fad70 Mon Sep 17 00:00:00 2001 From: Yonas Kolb Date: Sun, 12 Nov 2017 21:15:07 +0100 Subject: [PATCH] add support for linking directly to bundle or any directory with extension --- Sources/XcodeGenKit/SourceGenerator.swift | 5 ++--- .../TestProject/Project.xcodeproj/project.pbxproj | 13 +++++++++++++ .../TestProject/Resources/MyBundle.bundle/file.text | 0 Tests/Fixtures/TestProject/spec.yml | 1 + 4 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 Tests/Fixtures/TestProject/Resources/MyBundle.bundle/file.text diff --git a/Sources/XcodeGenKit/SourceGenerator.swift b/Sources/XcodeGenKit/SourceGenerator.swift index 1345a2dc..2125099e 100644 --- a/Sources/XcodeGenKit/SourceGenerator.swift +++ b/Sources/XcodeGenKit/SourceGenerator.swift @@ -183,9 +183,8 @@ class SourceGenerator { private func getSources(targetSource: TargetSource, path: Path, isRootSource: Bool) throws -> (sourceFiles: [SourceFile], groups: [PBXGroup]) { - let directoryFiles = ["xcassets"] // these are directories we should treat as files - let isDirectoryFile = path.extension != nil && directoryFiles.contains(path.extension!) - let isFile = path.isFile || isDirectoryFile + // treat all directories with extensions as files + let isFile = path.isFile || path.extension != nil let fileName = isFile && isRootSource ? targetSource.name : nil // if we have a file, move it to children and use the parent as the path diff --git a/Tests/Fixtures/TestProject/Project.xcodeproj/project.pbxproj b/Tests/Fixtures/TestProject/Project.xcodeproj/project.pbxproj index ee14dcf9..63f3b3ef 100644 --- a/Tests/Fixtures/TestProject/Project.xcodeproj/project.pbxproj +++ b/Tests/Fixtures/TestProject/Project.xcodeproj/project.pbxproj @@ -10,6 +10,7 @@ BF1401236301 /* Alamofire.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FR3032072501 /* Alamofire.framework */; }; BF1628293501 /* Standalone.swift in Sources */ = {isa = PBXBuildFile; fileRef = FR2554453101 /* Standalone.swift */; }; BF1744565901 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FR6218091901 /* ViewController.swift */; settings = {COMPILER_FLAGS = "-Werror"; }; }; + BF1762863701 /* MyBundle.bundle in Resources */ = {isa = PBXBuildFile; fileRef = FR2691220401 /* MyBundle.bundle */; }; BF2018435801 /* Framework_iOS.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = FR4722960401 /* Framework_iOS.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; BF2250910101 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = VG2043127501 /* Main.storyboard */; }; BF2301913502 /* MoreUnder.swift in Sources */ = {isa = PBXBuildFile; fileRef = FR8488480101 /* MoreUnder.swift */; }; @@ -76,6 +77,7 @@ FR1345298503 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; FR1473702401 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; FR2554453101 /* Standalone.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Standalone.swift; sourceTree = ""; }; + FR2691220401 /* MyBundle.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = MyBundle.bundle; sourceTree = ""; }; FR3032072501 /* Alamofire.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Alamofire.framework; sourceTree = ""; }; FR3032072502 /* Alamofire.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Alamofire.framework; sourceTree = ""; }; FR3032072503 /* Alamofire.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Alamofire.framework; sourceTree = ""; }; @@ -244,6 +246,15 @@ path = watchOS; sourceTree = ""; }; + G71894349401 /* Resources */ = { + isa = PBXGroup; + children = ( + FR2691220401 /* MyBundle.bundle */, + ); + name = Resources; + path = Resources; + sourceTree = ""; + }; G78312289901 /* App_iOS_Tests */ = { isa = PBXGroup; children = ( @@ -291,6 +302,7 @@ G46615002701 /* Framework */, G19527407101 /* Frameworks */, G86202385201 /* Products */, + G71894349401 /* Resources */, G66512504301 /* StandaloneFiles */, ); sourceTree = ""; @@ -519,6 +531,7 @@ BF4414242001 /* Localizable.stringsdict in Resources */, BF2513089601 /* LocalizedStoryboard.storyboard in Resources */, BF2250910101 /* Main.storyboard in Resources */, + BF1762863701 /* MyBundle.bundle in Resources */, BF2754797601 /* StandaloneAssets.xcassets in Resources */, ); }; diff --git a/Tests/Fixtures/TestProject/Resources/MyBundle.bundle/file.text b/Tests/Fixtures/TestProject/Resources/MyBundle.bundle/file.text new file mode 100644 index 00000000..e69de29b diff --git a/Tests/Fixtures/TestProject/spec.yml b/Tests/Fixtures/TestProject/spec.yml index cff43e89..f47a6d6b 100644 --- a/Tests/Fixtures/TestProject/spec.yml +++ b/Tests/Fixtures/TestProject/spec.yml @@ -19,6 +19,7 @@ targets: - "-Werror" - path: StandaloneFiles/Standalone.swift - FileGroup/UnderFileGroup + - Resources/MyBundle.bundle settings: PRODUCT_BUNDLE_IDENTIFIER: com.project$(BUNDLE_ID_SUFFIX) INFOPLIST_FILE: App_iOS/Info.plist