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
Tests and swift test
not working because 'Cannot load underlying module for XCTest'
#358
Comments
What version of Swift are you using with SPM? |
We have a ticket tracking package update. #297 I am not sure about 4.2. Follow this thread if you are interested: |
Hi @masters3d, I'm running the following: Apple Swift version 4.1.2 (swiftlang-902.0.54 clang-902.0.39.2)
Target: x86_64-apple-darwin17.7.0 Cheers, |
That should work. Try reinstalling Xcode and the command line tools for Xcode. Also you could instead just use swift package to generate an Xcode project |
It does work now - just originally |
|
We do the same with Circle CI with macOS. The only target do not test is windows because there is no Swift windows yet. Line 4 in 0017833
|
It does work now - just originally The reason for this issue was the incompleteness in your guide and wanted to chip in to make them more complete when people run into problems. Hope this help and it gets added to the guide ;-) Kind regards, |
Sounds good. Any improvement PR to our are documentation is more than welcome. Feel free to open up a new issue specifically about it or submit a PR. |
Hi,
I've successfully installed the exercism CLI app and checked out the first two challenges for the Swift track. I'm really eager to get started, but I've run into some problems...
The problem i'm facing is the following:
First thing I've noticed is that the
Package.swift
does not conform to the latest version and does not contain the tool directive in comments (no idea what the official name of this is):// swift-tools-version:4.0
. Apparently this is mandatory. I've found that hereIf i omit this directive it compiles via
swift build
. However when I add this directive, I get different error messages. When I then run eitherswift build
orswift test
(like it says in your guide) the SPM(Swift Package Manager) returns with awarning: no targets to build in package
to me.What i've tried so far:
--type executable
. This generates a more completePackage.swift
file. I wanted to see if this gives me the same results when usingswift build/test
. It did. I've also added thetestTarget
to thetargets
. It should look something like this:One thing that is different from your project than from the project that i've generated via spm, is that the spm project also generates another folder in the
Sources
folder with the name of the project. In my case that wasTesting
. In there is a.swift
file calledTesting
. If you try to runswift test
without this change it throws an error like thiserror: could not find target(s): Testing; use the 'path' property in the Swift 4 manifest to set a custom target path
.When I run the tests now it gives me an error:
"xcrun: error: unable to find utility "xctest", not a developer tool or in PATH"
. Runningxctest
can be done viaxcrun xctest
in the Terminal. This give a bunch of output and there is a path in theArguments
node.So following the the hint from the error I've added the
"/Applications/Xcode.app/Contents/Developer/usr/bin/"
to my path viaexport PATH="$PATH:/Applications/Xcode.app/Contents/Developer/usr/bin/"
. To confirm that it works check it with anecho $PATH
.Now when calling
swift test
I get to see the correct output, tests pass and it all works!If that still does not work; After searching github and SO I've found this which talks about Why isn't swift build able to link XCTest?.
They say this:
The solution they propose is adding the search paths to
swift build
like soWhen doing the same but for
swift test
I get to see the correct output, tests pass and it all works!What I've also done (and later removed because
swift test
worked regardless of adding the search paths) is to create an alias which includes the search paths so you only have to typeswift test
and be done with it.Hope this helps anyone who has run into the same problems. Or maybe add this to your docs if people have the same problem.
Kind regards,
Sidney de Koning
The text was updated successfully, but these errors were encountered: