Skip to content

Cannot @testable import executable target with --build-tests flag #9080

@bo2themax

Description

@bo2themax

Is it reproducible with SwiftPM command-line tools: swift build, swift test, swift package etc?

  • Confirmed reproduction steps with SwiftPM CLI. The description text must include reproduction steps with either of command-line SwiftPM commands, swift build, swift test, swift package etc.

Description

Similar error with #7596

./swift-java/Tests/SwiftJavaToolTests/JavaRepositoryTests.swift:17:18: error: no such module 'SwiftJavaTool'
 15 | import Foundation
 16 | @testable import SwiftJavaConfigurationShared
 17 | @testable import SwiftJavaTool
    |                  `- error: no such module 'SwiftJavaTool'
 18 | import Testing
  • swift build --build-tests --disable-sandbox failed to build
  • swift build --disable-sandbox && swift test succeeded

Steps to reproduce

swift build --build-tests --disable-sandbox with swift-java #374 on 967ccafcf1b6f88b14fd6e1288bc76693cf66369

git clone https://github.com/swiftlang/swift-java.git swift-java-apple && cd swift-java-apple
gh pr checkout 374
git checkout 967ccaf
swift build --build-tests --disable-sandbox

Swift & OS version (output of swift --version ; uname -a)

swift-driver version: 1.127.14.1 Apple Swift version 6.2 (swiftlang-6.2.0.19.9 clang-1700.3.19.1)
Target: arm64-apple-macosx26.0
Darwin 25.0.0 Darwin Kernel Version 25.0.0: Thu Aug 14 22:03:34 PDT 2025; root:xnu-12377.1.8~5/RELEASE_ARM64_T6030 arm64

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions