morpheus
(morpheus)
1
Hello,
I am writing my first program in Swift just to check it out. I downloaded following release without Xcode from Swift.org - Not Found
% swift --version
Apple Swift version 5.7.2 (swift-5.7.2-RELEASE)
Target: arm64-apple-macosx13.0
I created a scaffold project using the command line but when I try to run tests I get this error:
% swift test
error: XCTest not available
How can I fix this? I tried searching online but could not find any solution.
PS: I don't want to install Xcode
Jon_Shier
(Jon Shier)
2
Install Xcode. Toolchains aren't meant to be used without it. You might be able to get away with just the command line tools instead, but I doubt it.
1 Like
0xTim
(Tim)
3
This is a known issues because the Swift toolchain doesn't include the Objective-C runtime which is what's used on macOS for testing - [SR-15020] swift test fails on macOS without Xcode · Issue #4396 · apple/swift-package-manager · GitHub
As an FYI it's a long term goal of the SSWG to be able to build Swift projects on macOS with just the toolchain and no' Xcode, e.g. using VSCode
3 Likes
morpheus
(morpheus)
4
Thanks Tim. Is there any way to test without XCTest? perhaps another test framework?
0xTim
(Tim)
5
Unfortunately not, no. At least not without writing a new subcommand to call instead of swift test or forking Swift and changing the way swift test works
dabrahams
(Dave Abrahams)
6
And what does it mean if I have Xcode installed but I'm still getting that message?
0xTim
(Tim)
7
Make sure Homebrew hasn't screwed up the Swift installation by running sudo xcode-select -s /Applications/Xcode.app (or wherever you have Xcode installed). Homebrew has a habit of overriding the command line tools with whatever it needs which can cause issues like this
1 Like
dabrahams
(Dave Abrahams)
8
Thanks; I am learning to loathe Homebrew more each day.
Panajev
(Goffredo Marocchi)
9
I have to say that in about 10 years of using MacPorts first and for about 6-7 of those years of using Homebrew (created a portable config / setup that goes on every of the team’s machines including the CI build agents which run macOS, now bare metal IaaS on Flow.Swiss) I have never seen it mess with the command line tools path which does not mean it cannot happen, maybe we avoided it. I can add it to the list of things to be on the lookout for, but not something I can complain about Homebrew. It definitely helped us automate our setup more.
Why do you hate homebrew (I know hate is a strong word :))? I have much more of an issue with either the lack of access to some command line tools or having an older version than needed because of licensing constraints on macOS… for a lot of things this helps with an environment that is closer to upstream and easier to get help with as a result.
dabrahams
(Dave Abrahams)
10
It's perhaps a very personal thing that nobody else runs into, but the course of this issue pretty much sums it up.
Panajev
(Goffredo Marocchi)
11
Oh no worries, they were a bit rude… it is weird why you are not seeing the shellenv bit in the installer script output.
It seems like something is missing from the Intel homebrew setup…
I have not checked that in a while as we saved that step in the brew installed setup phase: