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 when trying to generate for a unit test module #714

Open
DerSeegler opened this issue Oct 18, 2021 · 8 comments
Open

Error when trying to generate for a unit test module #714

DerSeegler opened this issue Oct 18, 2021 · 8 comments

Comments

@DerSeegler
Copy link

I'm trying to generate the documentation for our unit test module, and I am getting an error. It worked for the main module though, and it also worked for the tests a couple of years ago, so not sure what's changed.

My command is:
sourcekitten doc --module-name [ProjectName]Test -- -workspace [ProjectName].xcworkspace -scheme "[ProjectName] Dev" clean build > swiftDoc.json

And I get the following error:

Could not parse compiler arguments from `xcodebuild` output.
Please confirm that `xcodebuild` is building a Swift module.
Saved `xcodebuild` log file: /var/folders/8w/w7k_803179l5pbqzm47mxx4c0000gn/T/xcodebuild-2EEBEE83-7072-42FB-A8C6-5688FF202D93.log
Error: Failed to generate documentation

But the xcodebuild log shows "** BUILD SUCCEEDED **" as the last line.

Sourcekitten version: 0.31.1
Xcode version 13.0

@johnfairh
Copy link
Collaborator

You should check the rest of the log file: sourcekitten is saying that it doesn't contain a swiftc command to build the module [ProjectName]Test.

@DerSeegler
Copy link
Author

First of all thanks for your quick answer, and sorry for my late response.

You are totally right. The command I posted doesn't build the test module. So I adapted the command to the following:
sourcekitten doc --module-name [ProjectName]Test -- -workspace [ProjectName].xcworkspace -scheme "[ProjectName] Dev" -destination id=F1BC1B0A-E7DE-4FF2-89C5-F0590305FAB8 clean test > swiftDoc.json

The log now ends with:

Result bundle written to path:

/Users/[user]/Library/Developer/Xcode/DerivedData/[ProjectName]-gndxzgdzvemytffwnupttgzjqyjm/Logs/Test/Run-[ProjectName] Dev-2021.11.01_2-19-04-+0100.xcresult

** BUILD SUCCEEDED **

Testing started

But Sourcekitten still says the same error.

@johnfairh
Copy link
Collaborator

The build command sourcekitten is looking for starts with /usr/bin/swiftc and contains the flag -module-name [ProjectName]Test. Maybe check through the log and see what modules are being built?

@DerSeegler
Copy link
Author

Yes it contains it:

CompileSwiftSources normal x86_64 com.apple.xcode.tools.swift.compiler (in target '[ProjectName]Tests' from project '[ProjectName]')
    cd /Users/[UserName]/[ProjectName]/src
    export DEVELOPER_DIR\=/Applications/Xcode.app/Contents/Developer
    export SDKROOT\=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.0.sdk
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -incremental -module-name [ProjectName]Tests
[...]

@johnfairh
Copy link
Collaborator

johnfairh commented Nov 5, 2021

That says [ProjectName]Tests but your CLI command says [ProjectName]Test (without the 's').

Is the typo in this GitHub issue or the actual problem? I'm only grasping at this nitpicky straw because it's the only thing I can think of -- this works elsewhere for loads of users!

@DerSeegler
Copy link
Author

Wow great find. That was indeed the problem. Now it runs through without errors, but the resulting json only contains [].

@johnfairh
Copy link
Collaborator

If that keeps happening after clearing up .build, build, and DerivedData for the project then I think that's as far as we can take it without a recreating project.

This works for me on a rare Xcode-test-setup project I have:

; sourcekitten doc --module-name TMLPersistentContainerTests -- clean build-for-testing -scheme TMLPersistentContainer-macOS > test.json
--- xcodebuild: WARNING: Using the first of multiple matching destinations:
{ platform:macOS, arch:x86_64, id:E26C7320-8430-5C92-B867-3503C5EE80F5 }
{ platform:macOS, name:Any Mac }
--- xcodebuild: WARNING: Using the first of multiple matching destinations:
{ platform:macOS, arch:x86_64, id:E26C7320-8430-5C92-B867-3503C5EE80F5 }
{ platform:macOS, name:Any Mac }
Running xcodebuild
Parsing MultiItem1_1+CoreDataClass.swift (1/35)
Parsing MultiItem1_1+CoreDataProperties.swift (2/35)
Parsing MultiItem2_1+CoreDataClass.swift (3/35)
Parsing MultiItem2_1+CoreDataProperties.swift (4/35)
[...]
Parsing TestSimpleMigrate.swift (35/35)
; wc -l test.json
   13775 test.json

@DerSeegler
Copy link
Author

Hm, maybe it has something to do with the fact, that I am using an old version, because the new version enforces that signing is disabled, which makes my build fail:

: no identity found
: no identity found
: no identity found
: no identity found
: no identity found
Command PhaseScriptExecution failed with a nonzero exit code

** TEST BUILD FAILED **

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

No branches or pull requests

2 participants