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

[iOS Xcode] Unable to generate documentation for module header files (.h) defined in bridging header for ObjectiveC and swift mixed project. #1349

Closed
GeethaTesting opened this issue Apr 29, 2023 · 6 comments
Labels

Comments

@GeethaTesting
Copy link

Using below commands to generate the documentation for ObjectiveC and Swift mixed project.

sourcekitten doc -- -workspace Infinite.xcworkspace -scheme Infinite > swiftDoc.json
This command is generating swiftDoc.json successfully.

sourcekitten doc --objc $(pwd)/Infinite/Infinite/Infinite.h -- -x objective-c -isysroot $(xcrun --show-sdk-path --sdk iphonesimulator) -I $(pwd) -fmodules > objcDoc.json
This command is unable to generate objcDoc.json file. It is giving the below error.

Error -
/Users/XXX/Downloads/Modular/Infinite/Infinite/Infinite.h:20:9: fatal error: 'Infinite/PropertyAnimatorViewController.h' file not found
/Users/XXX/Downloads/Modular/Infinite/Infinite/Infinite.h:20:9: error: 'Infinite/PropertyAnimatorViewController.h' file not found
#import <Infinite/PropertyAnimatorViewController.h>
^
:0: error: failed to import bridging header '/Users/XXX/Downloads/Modular/Infinite/Infinite/Infinite.h'

Sample Project attached.
Modular.zip

Screenshot 2023-04-30 at 12 06 45 AM

Kindly help us in resolving this issue, its little urgent.

@johnfairh
Copy link
Collaborator

It looks like you need some more build flags to tell Clang where the headers are -- try reading around these notes.

@johnfairh johnfairh added the help label Apr 30, 2023
@GeethaTesting
Copy link
Author

GeethaTesting commented May 3, 2023

@johnfairh - Thanks for your quick response, I followed the link and tried the steps as stated.
when i run below clang command, it executed successfully

>>clang -c -x objective-c -isysroot $(xcrun --show-sdk-path) -I $(pwd) Infinite/Infinite/Infinite.h -fmodules

After that i ran below Jazzy command, it executed successfully but not generated any documentation.

jazzy --objc --umbrella-header Infinite/Infinite/Infinite.h --framework-root $(pwd)                   
0% documentation coverage with 2 undocumented symbols
included 2 symbols
building site
building search index
jam out ♪♫ to your fresh new docs in `docs`

I also tried SourceKitten command to generate the ObjectiveC json file but no luck.

sourcekitten doc --objc $(pwd)/Infinite/Infinite/Infinite.h -- -x objective-c  -I $(pwd) Infinite/Infinite/Infinite.h -fmodules > objcDoc.json
zsh: trace trap  sourcekitten doc --objc $(pwd)/Infinite/Infinite/Infinite.h -- -x objective-c

Could you please help us in generating the documentation for attached codebase.
Modular.zip

@johnfairh
Copy link
Collaborator

Here's what happens when I run the clang command you say works for you:

; clang -c -x objective-c -isysroot $(xcrun --show-sdk-path) -I $(pwd) Infinite/Infinite/Infinite.h -fmodules
Infinite/Infinite/Infinite.h:19:9: fatal error: 'Infinite/NSString+DateFormatter.h' file not found
#import <Infinite/NSString+DateFormatter.h>
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

...and I can see that the NSString+DateFormatter.h file's path is:

; find . -name NSString+DateFormatter.h 
./Infinite/Infinite/PublicAPI/NSString+DateFormatter.h

So this is exactly the problem that the link I posted above describes -- you need to decide how you want to solve it. Then when you have the clang command working correctly (ie. no error messages) you can pass the same flags to sourcekitten to generate the objcDoc.json.

@GeethaTesting
Copy link
Author

GeethaTesting commented May 7, 2023

Hello @johnfairh,
I tried to add symbolic link in the below attached project and executed clang command. Command executed successfully.

clang -c -x objective-c -isysroot $(xcrun --show-sdk-path) -I $(pwd) Infinite/Infinite/Infinite.h -fmodules

As suggested above I tried same command with sourcekitten and im getting below error. Attached screenshot for reference.

clang -c -x objective-c -isysroot $(xcrun --show-sdk-path) -I $(pwd) Infinite/Infinite/Infinite.h -fmodules
geethadevi@INCHEL-GXTG90HJ-7903 Modular % sourcekitten doc --objc $(pwd)/Infinite/Infinite/Infinite.h -- -x objective-c -isysroot $(xcrun --show-sdk-path) -I $(pwd) Infinite/Infinite/Infinite.h -fmodules
zsh: trace trap  sourcekitten doc --objc $(pwd)/Infinite/Infinite/Infinite.h -- -x objective-c

Screenshot 2023-05-07 at 9 27 25 PM

Modular.zip

@johnfairh
Copy link
Collaborator

johnfairh commented May 8, 2023

I think just a slight copy+paste mistake, the umbrella header file is appearing twice in the sourcekitten command which clang is not going to like. The command should be something like:

sourcekitten doc --objc $(pwd)/Infinite/Infinite/Infinite.h -- -x objective-c -isysroot $(xcrun --show-sdk-path) -I $(pwd) -fmodules

And check your very first comment - if your project is for iOS then you'll need to put back the --sdk iphonesimulator.

@GeethaTesting
Copy link
Author

@johnfairh Thanks a lot for your support. It's working fine and able to generate documentation successfully.

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

2 participants