Skip to content
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

Fix misidentification of .swift-suffixed directory as a Swift file #575

Merged
merged 3 commits into from
Jan 29, 2019

Conversation

1ec5
Copy link
Contributor

@1ec5 1ec5 commented Jan 28, 2019

A “.swift”-suffixed directory in xcodebuild arguments is no longer detected as a Swift file.

Fixes #574.

@1ec5 1ec5 changed the title Fixed misidentification of .swift-suffixed directory as a Swift file Fix misidentification of .swift-suffixed directory as a Swift file Jan 28, 2019
@jpsim
Copy link
Owner

jpsim commented Jan 28, 2019

This fix looks correct, I have to look into why it's failing tests on CI.

@jpsim
Copy link
Owner

jpsim commented Jan 28, 2019

Suggested changes:

diff --git a/Source/SourceKittenFramework/String+SourceKitten.swift b/Source/SourceKittenFramework/String+SourceKitten.swift
index f12a316..05e57cf 100644
--- a/Source/SourceKittenFramework/String+SourceKitten.swift
+++ b/Source/SourceKittenFramework/String+SourceKitten.swift
@@ -465,10 +465,6 @@ extension NSString {
 }
 
 extension String {
-    internal var isFileOrDirectory: Bool {
-        return FileManager.default.fileExists(atPath: self)
-    }
-
     internal var isFile: Bool {
         var isDirectory: ObjCBool = false
         let exists = FileManager.default.fileExists(atPath: self, isDirectory: &isDirectory)
diff --git a/Source/SourceKittenFramework/library_wrapper.swift b/Source/SourceKittenFramework/library_wrapper.swift
index 335130e..0651afe 100644
--- a/Source/SourceKittenFramework/library_wrapper.swift
+++ b/Source/SourceKittenFramework/library_wrapper.swift
@@ -42,7 +42,7 @@ let toolchainLoader = Loader(searchPaths: [
     userApplicationsDir?.xcodeDeveloperDir.toolchainDir,
     userApplicationsDir?.xcodeBetaDeveloperDir.toolchainDir
 ].compactMap { path in
-    if let fullPath = path?.usrLibDir, fullPath.isFile {
+    if let fullPath = path?.usrLibDir, FileManager.default.fileExists(atPath: fullPath) {
         return fullPath
     }
     return nil
@@ -53,7 +53,7 @@ struct Loader {
     let searchPaths: [String]
 
     func load(path: String) -> DynamicLinkLibrary {
-        let fullPaths = searchPaths.map { $0.appending(pathComponent: path) }.filter { $0.isFileOrDirectory }
+        let fullPaths = searchPaths.map { $0.appending(pathComponent: path) }.filter { $0.isFile }
 
         // try all fullPaths that contains target file,
         // then try loading with simple path that depends resolving to DYLD

Copy link
Owner

@jpsim jpsim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@jpsim jpsim merged commit 8b082a1 into jpsim:master Jan 29, 2019
@1ec5 1ec5 deleted the module-swift-folder-574 branch January 29, 2019 02:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Include directory suffixed with .swift causes doc command to fail
2 participants