Skip to content

Local testing on Mac not working (fix inside) #760

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

Open
kempsu opened this issue Jul 9, 2024 · 6 comments
Open

Local testing on Mac not working (fix inside) #760

kempsu opened this issue Jul 9, 2024 · 6 comments

Comments

@kempsu
Copy link

kempsu commented Jul 9, 2024

A common error is occuring because of incorrect SDK paths.

$ swift test
warning: could not determine XCTest paths: terminated(1): /usr/bin/xcrun --sdk macosx --show-sdk-platform-path output:
    xcrun: error: unable to lookup item 'PlatformPath' from command line tools installation
    xcrun: error: unable to lookup item 'PlatformPath' in SDK '/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk'

error: XCTest not available

You can fix this error as followed:

$ xcrun --show-sdk-path --sdk macosx

You might get this result:

/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk

Now change the default SDK location by invoking the following command:

$ sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer

If that also does not work, please take a look inside the regular SDK path:

$ ls -lat /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/

Normally you should see the SDKs inside this directory. If not, you'll need to download the SDKs first.

@meatball133
Copy link
Member

I am not really sure what this issue has to do with this repo? Feels like a swift issue or xcode issue. I use Swift frequently on Linux which have worst support than mac and xctest is builtin into the swift package and also which swift version do you use?

@kempsu
Copy link
Author

kempsu commented Jul 9, 2024

I wanted to raise the potential issue with the docs of the Swift track, sorry if that wasn't clear. The issue might have occured on my system because I also installed the XCode 16 Beta in parallel.

I am using the following swift version:
swift-driver version: 1.90.11.1 Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
Target: arm64-apple-macosx14.0

@erinn
Copy link

erinn commented Mar 30, 2025

Having run into this issue myself here is what I can say.

I reckon the CLI users are a subset of the folks using this site. However, it is a bad experience to have the CLI fail straight out of the gate on the very first task for the Swift track.

The issue is fairly simple once you know about it, but finding out about it can be difficult to understand, and especially for a beginner programmer may just turn them off of Swift in general.

I believe this could be fixed up with a little documentation, the gist of it is fairly simple:

You will need to have Xcode installed to use the Swift track locally. The command line tools Apple provides contain only a subset of the functionality that Xcode provides and do not include XCTest which is needed. If the user has both the command line tools and Xcode installed running xcode-select to point at the Xcode install will be necessary.

I can write up a PR on this, though you closed my last one saying you were in the middle of a rewrite so perhaps best if you do @meatball133?

To me, though this is a minor point and only affects a small portion of folks, I believe it is still a very important point. The experience for people to begin learning Swift should be easy and as clear as possible.

@meatball133
Copy link
Member

A few hours before this I actually rewrote the installation docs(#840), pointing to that if you aren't using/want to be using Xcode, you should install the binary separately. Meaning if you are planning to use editors other than XCode we will discourage you install Swift through Xcode.

What I understand the problem being is that you have installed Swift through xcode and then installed command line tools and then that doesn't automatically link the sdk. I have done a bit of research and this seems to be a quite common issue, but a quite common thing I found was that said person didn't use or want to use Xcode.

I am not using macOS so it is a bit hard to test what the experience is like. And how testing works without using the command line. What I mostly have to go of is what other people say and what Apple points at.

Also just to double check, are you using Xcode 16.x? If so we might put the first solution here, if your use case couldn't be satisfied through the non-Xcode path (if you are not using Xcode to begin with so to speak), but we can't have a full troubleshooting guide since that is just not possible.

@erinn
Copy link

erinn commented Mar 30, 2025

Assuming this is being written for beginners, the simplest thing to say in an installation document is along these lines:

If you wish to run the exercises locally on MacOS, install Xcode, you do to have to use Xcode, but Xcode includes all of the needed libraries to work.

If you have both Xcode and the command line tools installed, run $ sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer to ensure your copy of swift is pointing to the Xcode installation.

Anything beyond that in my opinion becomes full blown troubleshooting, but to the best of my knowledge this should get folks through 90% of the trouble. Insert appropriate links like to the exercism CLI docs, Apple's site for the CLI tools and Xcode in the App Store.

@erinn
Copy link

erinn commented Mar 30, 2025

And yes, I am running Xcode 16.2 and had had the Xcode Command Line tools installed which made the tests fail due to not having XCTest included in them.

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

3 participants