realm / jazzy

Soulful docs for Swift & Objective-C
https://realm.io
MIT License
7.35k stars 413 forks source link

Jazzy Unable to find an Xcode with swift version 2.2. (RuntimeError): Xcode7.3 #551

Closed sreedhargs89 closed 8 years ago

sreedhargs89 commented 8 years ago

We are trying to generate the documents for Swift2.2 using Jazzy with Xcode7.3. We have 2 environments: Local dev environment (Macbook) and Server machine for central build.

We have exactly same set up in both machine like Xcode,CommandLine tools,Ruby but in server Jazzy fails with the below error:

_jazzy-0.5.0/lib/jazzy/sourcekitten.rb:137:in `run_sourcekitten': Unable to find an Xcode with swift version 2.2. (RuntimeError)
from .../gems/jazzy-0.5.0/lib/jazzy/doc_builder.rb:57:in `block in build'
from .../gems/jazzy-0.5.0/lib/jazzy/doc_builder.rb:55:in `chdir'
from .../gems/jazzy-0.5.0/lib/jazzy/doc_builder.rb:55:in `build'
from .../gems/jazzy-0.5.0/bin/jazzy:15:in `<top (required)>'
from .../jazzy/bin/jazzy:23:in `load'
from .../jazzy/bin/jazzy:23:in `<main>'_

Forums suggested to use the --swift-version 2.2 but this didn't work for me.. :(

I further tried to debug the issue by looking into jazzy/gems/jazzy-0.5.0/lib/jazzy/sourcekitten.rb:137 file

Line 137: def self.run_sourcekitten(arguments) swift_version = Config.instance.swift_version unless xcode = XCInvoke::Xcode.find_swift_version(swift_version) raise "Unable to find an Xcode with swift version #{swift_version}." end bin_path = Pathname(__FILE__).parent + 'SourceKitten/bin/sourcekitten' output, = Executable.execute_command(bin_path, arguments, true, env: xcode.as_env) output end

Here it looks value of "xcode" is nil and jazzy unable to find the xcode with swift2.2

FYI:

- xcodebuild -version
Xcode 7.3
Build version 7D175
- xcrun swift --version
Apple Swift version 2.2 (swiftlang-703.0.18.1 clang-703.0.29)
Target: x86_64-apple-macosx10.9

Your help really appreciated.

sreedhargs89 commented 8 years ago

Any update on this issue...?

jpsim commented 8 years ago

No

mkieselmann commented 8 years ago

The problem was caused by the fact that the server machines have spotlight indexing disabled while it was enabled on the Macbook. Hence, line 36 in xcode.rb of the XCInvoke gem fails: xcodes, = Open3.capture2('mdfind', "kMDItemCFBundleIdentifier == 'com.apple.dt.Xcode'", err: '/dev/null')

The mdfind command relies on the spotlight metadata store which needs spotlight indexing to be enabled. Otherwise it won't find any Xcode versions.

Any suggestion how we can fix the problem? My first two ideas would be: 1) Getting the XCode paths without spotlight 2) Providing a command line parameter that specifies the XCode location

jpsim commented 8 years ago

427 would fix this.

mkieselmann commented 8 years ago

Great thanks 👍