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

Include directory suffixed with .swift causes doc command to fail #574

Closed
1ec5 opened this issue Jan 28, 2019 · 2 comments · Fixed by #575
Closed

Include directory suffixed with .swift causes doc command to fail #574

1ec5 opened this issue Jan 28, 2019 · 2 comments · Fixed by #575

Comments

@1ec5
Copy link
Contributor

1ec5 commented Jan 28, 2019

The Mapbox Navigation SDK for iOS runs jazzy passing in this podspec as --podspec. Among the errors we’re working through in mapbox/mapbox-navigation-ios#1795 is this one caused by the dependency on the MapboxDirections.swift pod:

Could not read contents of `/var/folders/cl/8cgpg37n5cl78pjkbpgml94w0000gn/T/jazzy20190128-87912-1r7txvvMapboxNavigation-Documentation/build/Release-iphoneos/MapboxDirections.swift`
Could not parse `MapboxDirections.swift`. Please open an issue at https://github.com/jpsim/SourceKitten/issues with the file contents.

CocoaPods places the pod’s downloaded framework inside a MapboxDirections.swift directory. jazzy passes the framework root’s path to xcodebuild as an include directory (-I). But the “.swift” suffix in the directory name causes SourceKitten to detect the folder as a Swift file:

public func isSwiftFile() -> Bool {
return pathExtension == "swift"
}

So then sourcekitten doc fails because Module.docs thinks it needs to parse a “MapboxDirections.swift” file for documentation:

self.init(name: moduleName, compilerArguments: arguments)
do {
_contents = try String(contentsOfFile: path, encoding: .utf8)
} catch {
fputs("Could not read contents of `\(path)`\n", stderr)
return nil
}

/cc @JThramer

@jpsim
Copy link
Owner

jpsim commented Jan 28, 2019

I think isSwiftFile is a red herring, since the only place where it's used in SourceKitten is here: https://github.com/jpsim/SourceKitten/blob/0.22.0/Source/SourceKittenFramework/Module.swift#L120

And that also validates that it's a file and not a directory.

sourceFiles = compilerArguments.filter({
    $0.bridge().isSwiftFile() && $0.isFile
}).map {
    return URL(fileURLWithPath: $0).resolvingSymlinksInPath().path
}

@jpsim
Copy link
Owner

jpsim commented Jan 28, 2019

Oops, you were right, the isFile helper is incorrect and also returns true for directories. Your fix at #575 looks good at a glance, we just have to figure out why it's failing CI.

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 a pull request may close this issue.

2 participants