Use custom swiftc or swift-frontend while running XCTest based tests in Xcode

Can I tell Xcode to use a custom swiftc or swift-frontend, i.e., one different from the active toolchain's swiftc or swift-frontend, while running XCTest based tests in Xcode?

It looks like setting the SWIFT_DRIVER_SWIFT_FRONTEND_EXEC environment variable in your target's scheme does the job.

Scratch that. It did not seem to work.

try setting SWIFT_EXEC in your project’s build settings to an absolute path to your custom swiftc executable

@kavon I have a Swift package (one w/ a Package.swift file). How can I modify the build settings for this? I see an options for setting environment variables for Run settings but nothing for build settings.

You can set that SWIFT_EXEC environment variable in your terminal’s shell. when running ‘swift build’ it should use that swiftc for compilation.