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

'Could not parse compiler arguments' when documenting Obj-C Framework #492

Closed
gbernady opened this issue Feb 26, 2016 · 9 comments
Closed
Assignees
Labels

Comments

@gbernady
Copy link

I have a project consisting of a bunch of Obj-C Frameworks (soon to include Swift code) and an app, all residing in a single workspace. When I run jazzy to document one of the Frameworks, I get the Could not parse compiler arguments from 'xcodebuild' output. error.

Here's a sample project reproducing the issue.

And logs:

/D/Foo ❯❯❯ ./doc.sh + jazzy --objc --author foo --module-version 1.0.0 --umbrella-header Libraries/Bar/Bar/Bar.h --framework-root Libraries/Bar --module Bar --sdk iphoneos -x -workspace,Foo.xcworkspace,-scheme,Bar
Running xcodebuild
Could not parse compiler arguments from xcodebuild output.
Please confirm that xcodebuild is building a Swift module.
Saved xcodebuild log file: /var/folders/qd/23r2s42j5xs78mqsm3_pss_926b9jc/T/xcodebuild-8B4A01F2-2459-4942-A533-DC660E86521F.log
Failed to generate documentation
/Library/Ruby/Gems/2.0.0/gems/jazzy-0.5.0/lib/jazzy/executable.rb:36:in `execute_command': /Library/Ruby/Gems/2.0.0/gems/jazzy-0.5.0/lib/jazzy/SourceKitten/bin/sourcekitten > "doc", "-workspace", "Foo.xcworkspace", "-scheme", "Bar"

Running xcodebuild

Could not parse compiler arguments from xcodebuild output.

Please confirm that xcodebuild is building a Swift module.

Saved xcodebuild log file: /var/folders/qd/23r2s42j5xs78mqsm3_pss_926b9jc/T/xcodebuild-8B4A01F2-2459-4942-A533-DC660E86521F.log

Failed to generate documentation
from /Library/Ruby/Gems/2.0.0/gems/jazzy-0.5.0/lib/jazzy/sourcekitten.rb:140:in run_sourcekitten' from /Library/Ruby/Gems/2.0.0/gems/jazzy-0.5.0/lib/jazzy/doc_builder.rb:57:inblock in build'
from /Library/Ruby/Gems/2.0.0/gems/jazzy-0.5.0/lib/jazzy/doc_builder.rb:55:in chdir' from /Library/Ruby/Gems/2.0.0/gems/jazzy-0.5.0/lib/jazzy/doc_builder.rb:55:inbuild'
from /Library/Ruby/Gems/2.0.0/gems/jazzy-0.5.0/bin/jazzy:15:in <top (required)>' from /usr/local/bin/jazzy:23:inload'
from /usr/local/bin/jazzy:23:in `

'

What's interesting, if I add a Swift class to my Framework, the error disappears. However only the one Swift class is documented.

Am I missing something? I'm using jazzy 0.5.0 and Xcode 7.2.1. I would really appreciate some help in diagnosing the issue.

@rastersize
Copy link

AFAIK if you override the parameters passed to xcodebuild (i.e. via the -x flag) you must also send all options. E.g. see how Realm does it in https://github.com/realm/realm-cocoa/blob/master/build.sh#L239

In your case I guess that would be something like:

jazzy \
    --objc \
    --author foo \
    --module Bar \
    --module-version 1.0.0 \
    --xcodebuild-arguments --objc,Libraries/Bar/Bar/Bar.h,-x,objective-c,-isysroot,$(xcrun --show-sdk-path),-I,Libraries/Bar

However you might be able to drop all of the --xcodebuild-arguments stuff. That works for our (quite complex) Objective-C library.

@jpsim
Copy link
Collaborator

jpsim commented Apr 6, 2016

@rastersize is correct, that -x arguments will override any arguments to be sent to SourceKitten/Xcode that would otherwise be set by jazzy, which includes --objc, which is why the error disappears when you have a single Swift class, because jazzy then tries to document your "Swift" project. So just prepend --objc to your -x arguments.

@jpsim jpsim added the question label Apr 6, 2016
@gbernady
Copy link
Author

gbernady commented Apr 6, 2016

Thanks! I tried adding just the --obj to -x and... clang crashed. Then I started rewriting the jazzy invocation command as suggested by @rastersize, every time encountering the same crash.

In the end I got to something like

xcode_args="--objc,Libraries/Bar/Bar/Bar.h,-x,objective-c,-isysroot,$(xcrun --sdk iphoneos --show-sdk-path),-I,$(pwd),-workspace,Foo.xcworkspace,-scheme,Bar"
jazzy \
  --objc \
  --clean \
  --author foo \
  --module-version 1.0.0 \
  --module Bar \
  --xcodebuild-arguments $xcode_args

With the crash every time looking like this

libclang: crash detected during parsing: {
  'source_filename' : 'Libraries/Bar/Bar/Bar.h'
  'command_line_args' : ['-x', 'objective-c', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.3.sdk', '-I', '/Users/berng/Downloads/Foo', '-workspace', 'Foo.xcworkspace', '-scheme', 'Bar'],
  'unsaved_files' : [],
  'options' : 1,
}

Is there a way to pass the workspace and scheme to jazzy other than xcodebuild arguments?

@jpsim
Copy link
Collaborator

jpsim commented Apr 6, 2016

If you share a project that reproduces the issue I'll be able to troubleshoot this with you... otherwise it'll be challenging.

Is there a way to pass the workspace and scheme to jazzy other than xcodebuild arguments?

Not for Objective-C just yet, but we are tracking that as jpsim/SourceKitten#88

@gbernady
Copy link
Author

gbernady commented Apr 6, 2016

Here's the sample project I'm using - Foo.zip

I just ran it on my second machine, and:

  • jazzy 0.5.0 does not report any crashes or errors, but the docs are empty.
  • jazzy 0.6.0 fails with the following error
    Unrecognized arguments: -x, -soiryt, -I, -awrpcosek, -semch
    /Users/gregor/.gem/ruby/2.3.0/gems/jazzy-0.6.0/lib/jazzy/executable.rb:36:in `execute_command': /Users/gregor/.gem/ruby/2.3.0/gems/jazzy-0.6.0/lib/jazzy/SourceKitten/bin/sourcekitten ["doc", "--objc", "Libraries/Bar/Bar/Bar.h", "-x", "objective-c", "-isysroot", "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.3.sdk", "-I", "/Users/gregor/Downloads/Foo", "-workspace", "Foo.xcworkspace", "-scheme", "Bar"] (RuntimeError)

    Unrecognized arguments: -x, -soiryt, -I, -awrpcosek, -semch
        from /Users/gregor/.gem/ruby/2.3.0/gems/jazzy-0.6.0/lib/jazzy/sourcekitten.rb:142:in `run_sourcekitten'
        from /Users/gregor/.gem/ruby/2.3.0/gems/jazzy-0.6.0/lib/jazzy/doc_builder.rb:56:in `block in build'
        from /Users/gregor/.gem/ruby/2.3.0/gems/jazzy-0.6.0/lib/jazzy/doc_builder.rb:54:in `chdir'
        from /Users/gregor/.gem/ruby/2.3.0/gems/jazzy-0.6.0/lib/jazzy/doc_builder.rb:54:in `build'
        from /Users/gregor/.gem/ruby/2.3.0/gems/jazzy-0.6.0/bin/jazzy:15:in `<top (required)>'
        from /Users/gregor/.gem/ruby/2.3.0/bin/jazzy:23:in `load'
        from /Users/gregor/.gem/ruby/2.3.0/bin/jazzy:23:in `<main>'

I did not encounter the libclang crash however, so it may have something to do with my main machine's configuration. I'll look into it tomorrow. I'm not even sure what version of jazzy I have on my main machine. I think it is 0.5.0.

I saw a similar problem with libclang also reported in #479.

@jpsim
Copy link
Collaborator

jpsim commented Apr 6, 2016

Here's what your doc.sh should look like:

jazzy \
  --objc \
  --swift-version 2.2 \
  --clean \
  --sdk iphonesimulator \
  --umbrella-header Libraries/Bar/Bar/Bar.h \
  --framework-root Libraries/Bar \
  --author foo \
  --module-version 1.0.0 \
  --module Bar

That works fine for me with Jazzy 0.6.0.

You'll also need to use Objective-C style documentation comments for them to be picked up by jazzy. In other words, replacing /*! with /**:

/**
 * Sample class description.
 */
@interface Baz : NSObject

/// A property.
@property (nonatomic) NSString *baz;

/**
 * Does something.
 *
 * @return YES if it did something, no otherwise.
 */
- (BOOL)doSomething;

@end

If I make those changes, the following documentation is generated: http://static.realm.io/jazzy_demo/GH492/index.html

Finally, if you want to still provide xcodebuild arguments directly, for now you'll need to prepend them with --.

@gbernady
Copy link
Author

gbernady commented Apr 6, 2016

Thanks a lot! It works. I'm actually glad I don't have to use the xcodebuild arguments.

As for the /*! comment blocks, I just assumed they are supported, because HeaderDoc, Xcode and Doxygen all recognize them.

@jpsim
Copy link
Collaborator

jpsim commented Apr 6, 2016

Ah, I wasn't familiar with that syntax. I just created a ticket to track supporting that: #517.

I'm glad we got all this worked out!

@jpsim jpsim closed this as completed Apr 6, 2016
@gbernady
Copy link
Author

gbernady commented Apr 6, 2016

Me too! Thanks again.

@istx25 istx25 modified the milestones: The Past, Before November 23rd, 2016 Nov 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants