swift-package-manager: Testing macros in the OSS toolchain snapshots for macOS don't seem to work with SDK bundles
Description
I recently added the Testing library to my Android SDK bundles for Swift 6.1 and 6.2, finagolfin/swift-android-sdk@eb1567b1c, and it works well to cross-compile Testing tests using the latest linux snapshot toolchain and my CI-generated 6.1 SDK bundle, which I checked by cross-compiling @tayloraswift’s swift-png and its tests. 😄
However, @marcprux tells me the same didn’t work with the OSS mac toolchain snapshot when he tried it with another Testing repo, as he got errors saying:
error: external macro implementation type 'TestingMacros.TestDeclarationMacro' could not be found for macro 'Test'; plugin for module 'TestingMacros' not found
suggesting there is some issue with how these Testing macros are installed on macOS.
Reproduction
Follow the instructions to use my Android SDK bundle on macOS, except using the 6.1 bundle linked above, not 6.0.3 as I have not backported the Android patches in this repo to that tag. An alternative would be to try the linux SDK bundle generated by swift-sdk-generator, if it supports this Testing library.
Expected behavior
Testing tests cross-compile fine using the mac toolchain’s prebuilt macros, as they do on linux.
Environment
MacOS
Additional information
I have not reproduced this myself. Marc said he’d file this himself, but I’m doing it now so we don’t forget and so somebody behind this repo can take a look in the meantime.
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 25 (25 by maintainers)
Commits related to this issue
- Update host toolchain installation for macOS to copy libTestingMacros.dylib to lib/swift/host/plugins/ (works around https://github.com/swiftlang/swift-package-manager/issues/8362) — committed to swift-android-sdk/swift-android-action by marcprux 2 years ago
- Handle exit code EXIT_NO_TESTS_FOUND (69) when Testing finds no test cases (see https://github.com/swiftlang/swift-package-manager/issues/8362#issuecomment-2719173349) — committed to swift-android-sdk/swift-android-action by marcprux 2 years ago
Possibly fixed by #8670, Marc, try it with the next trunk snapshot toolchain and let us know.
Looks like this is, or at least was, a bug in Swift Package Manager: in 6.1, it was checking whether the target triple represented macOS, and only then included the necessary macro plugin search paths to locate
libTestingMacros.dylibin macOS toolchains. I think that was happening here (link from therelease/6.1branch):https://github.com/swiftlang/swift-package-manager/blob/release/6.1/Sources/PackageModel/UserToolchain.swift#L676-L684
However, this code all changed somewhat recently in https://github.com/swiftlang/swift-package-manager/pull/8295 and it might have affected this, or perhaps even fixed the issue. I’m not certain, but it would be worth trying using a
maindevelopment snapshot toolchain which has that change to see.Regardless, I’m going to transfer this to SwiftPM since it’s something controlled at that layer. It may be a dupe, though.
I don’t think it is, as the upcoming 6.1 toolchain for linux only has
swift-6.1-DEVELOPMENT-SNAPSHOT-2025-03-07-a-fedora39/usr/lib/swift/linux/Testing.swiftmodule/x86_64-unknown-linux-gnu.swiftmoduleand the aforementioned pluginusr/lib/swift/host/plugins/libTestingMacros.so, works fine with my 6.1 Android SDK bundle.