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

error: use of '@import' when modules are disabled #636

Closed
TitouanVanBelle opened this issue Aug 12, 2016 · 8 comments
Closed

error: use of '@import' when modules are disabled #636

TitouanVanBelle opened this issue Aug 12, 2016 · 8 comments

Comments

@TitouanVanBelle
Copy link

I am running into these errors when running the following command

15:08:48 - tito@lt0311-2 Jazzy(master)> be jazzy --objc --umbrella-header Jazzy/SDK.h --theme apple --framework-root . --sdk iphoneos --module FyberSDK
/Users/tito/Documents/workspace/fyber/Jazzy/Jazzy/SDK.h:9:1: error: use of '@import' when modules are disabled
/Users/tito/Documents/workspace/fyber/Jazzy/Jazzy/Enum.h:9:1: error: use of '@import' when modules are disabled
/Users/tito/Documents/workspace/fyber/Jazzy/Jazzy/Enum.h:14:36: error: function definition declared 'typedef'
/Users/tito/Documents/workspace/fyber/Jazzy/Jazzy/Enum.h:14:9: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
/Users/tito/Documents/workspace/fyber/Jazzy/Jazzy/Enum.h:18:5: error: use of undeclared identifier 'MyEnumA'
/Users/tito/Documents/workspace/fyber/Jazzy/Jazzy/Enum.h:23:5: error: use of undeclared identifier 'MyEnumB'
/Users/tito/Documents/workspace/fyber/Jazzy/Jazzy/Enum.h:28:5: error: use of undeclared identifier 'MyEnumC'
building site
jam out ♪♫ to your fresh new docs in `docs`

I checked and modules are enabled for the target

//:configuration = Debug
CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = NO
CLANG_ENABLE_MODULES = YES

//:configuration = Release
CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = NO
CLANG_ENABLE_MODULES = YES

//:completeSettings = some
CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES
CLANG_ENABLE_MODULES
CLANG_MODULES_AUTOLINK

I am using the following version of jazzy

15:08:46 - tito@lt0311-2 Jazzy(master)> be jazzy -v
jazzy version: 0.7.0

I created a simple project that can reproduce the issue
https://github.com/TitouanVanBelle/JazzySampleProject

@pigeon-archive
Copy link
Contributor

Hi @TitouanVanBelle. Thanks for reaching out about this. I'll do my best to look through the resources you've shared, do some digging and come back with what I come up with. Cheers!

@TitouanVanBelle
Copy link
Author

Hi @istx25. Anything new regarding this?
Cheers!

@khallmark
Copy link

I'm getting this error also @istx25. Anything we can do?

@jpsim
Copy link
Collaborator

jpsim commented Apr 13, 2017

Someone needs to debug more in-depth to see what libclang flags are needed to support this.

@mgrebenets
Copy link
Contributor

mgrebenets commented May 2, 2017

 It got a bit better with 0.8.0.

Running command like this:

jazzy --objc \
  --sdk iphonesimulator \
  --umbrella-header Sources/XYZUtil.h \
  --module XYZUtil \
  --framework-root Sources \
  --no-download-badge \
  --module-version 1.0.0

I still get a lot of error: use of '@import' when modules are disabled errors, but at the end of it I actually get the documentation:

fatal error: too many errors emitted, stopping now [-ferror-limit=]
100% documentation coverage with 0 undocumented symbols
building site
building search index
jam out ♪♫ to your fresh new docs in `docs`

But it only works if my umbrella header uses "legacy" #import <Foundation/Foundation.h> import. As soon as I change it to @import Foundation; it fails completely, because it can't recognize symbols like FOUNDATION_EXPORT any more.

Trying to add -x -workspace,XYZUtil.xcworkspace,-scheme,XYZUtil will cause the mangled options issue:

Unrecognized arguments: -I, -I, -I, -I, -I, -I, -awrpcosek, -semch

Trying stuff like -x --,--objc,-workspace,XYZUtil.xcworkspace,-scheme,XYZUtil doesn't help much:

Unrecognized arguments: -I, -I, -I, -I, -I, -I

Still a good progress for me, cause I went from not being able to generate ObjC documentation to much better situation - I can get the doco, with minor caveats and few warnings in output.

@mgrebenets
Copy link
Contributor

mgrebenets commented May 2, 2017

So adding -x -fmodules along with fix in #797 helps jazzy to understand module imports.

Still, I couldn't figure out how to make it work with #import <MyFramework/PublicHeader.h> imports in umbrella header...
For now I had to resort to using #import "PublicHeader.h" syntax, which is compatible with xcodebuild and CocoaPods.

Also, jazzy can't understand 3rd party module imports, e.g. @import AFNetworking; or similar. That's because it's not building using workspace with CocoaPods included. I tried to use -workspace,...,-scheme,... options the same way it worked with Swift, but no luck.

The fact that 3rd party module imports are not recognized doesn't actually impact generated documentation.

mgrebenets added a commit to mgrebenets/jazzy that referenced this issue May 3, 2017
mgrebenets added a commit to mgrebenets/jazzy that referenced this issue May 3, 2017
mgrebenets added a commit to mgrebenets/jazzy that referenced this issue May 3, 2017
mgrebenets added a commit to mgrebenets/jazzy that referenced this issue May 3, 2017
@mgrebenets
Copy link
Contributor

Update: I've just found a way to make #import <MyFramework/PublicHeader.h> work as well.
The workaround was mentioned in #667 by @rnystrom.
Here's an example: Instagram/IGListKit#93

I was able to achieve same results with symlink: ln -s Sources ModuleName.
To make it work the framework root should be current working directory (.) and not Sources or ModuleName.

@jpsim
Copy link
Collaborator

jpsim commented May 11, 2017

Fixed in #798. Thanks for your patience.

@jpsim jpsim closed this as completed May 11, 2017
zsstrehli pushed a commit to zsstrehli/jazzy that referenced this issue Jun 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants