Whenever I try building SwiftPM as part of a build of Swift on Linux it fails with this error:
/swift_source/swiftpm/TSC/Sources/TSCTestSupport/AssertMatch.swift:11:8: error: no such module 'XCTest'
I did specify --xctest=1 in my build-script arguments.
Any help appreciated!
Could you provide your full build-script invocation?
That particular run was with this command below. I also tried it with
Right now I'm doing a run with just
--swiftpm=1 --libicu=1 -R to see if maybe one of the other commands was responsible for SPM needing to build TSC. But it seems like a bug to me that if
--xctest are specified then, it still can't find Xctest.
PS—I've tried building with the buildbot_linux but it always fails because I haven't specified an installable package path. But I'm not trying to make an installable package so I gave up on that.
You probably need
--install-xctest. You might want to try the
--infer option that @Michael_Gottesman added: [build-script] Automatic inferences of dependencies using new option: "--infer"
Alternatively, you could start with a preset and edit it to suit your needs. For example,
$ build-script --preset=buildbot_linux --expand-invocation install_destdir=/ installable_package=/fake2
will show what the preset expands to. If you don't want to build an installable package you can remove
--installable-package /fake2 before building.
I'm building Swift 5.2.4... is there a way to use --infer with 5.2.4 or would I have to cherry-pick build-script from master branch?
Thanks for the tips, will try these.
You're probably best off using the preset and have it create an installable package, even if you don't use it (or you could just modify
utils/build-presets.ini to not create an installable package for that preset, as Ben said).
If you really want to customize your build, your long command above can be minimized down to:
Note that I added
--install-xctest as Ben mentioned, without which you won't be able to build SwiftPM. All the
--skip-test-* flags shouldn't be needed as those aren't built or tested by default. Foundation and libdispatch are implicitly built if XCTest is built.
As I mentioned in your other thread, this install will likely overwrite any libicu, lldb, clang, etc. packages you already have installed in
/usr, so you may not want to override destdir if that's the case.