Tests cannot find SPM Resource bundles
What happened?
I've been trying to update my work project from Tuist 4.13.0 to Tuist 4.30.0, but I encountered a number of issues. Most of them were surmountable, but I've finally hit against one that I can't get past.
When attempting to run a snapshot test on a view in one of our feature modules which pulls in one of our other feature modules, and ultimately uses a view from Stripe's StripePaymentsUI library, I get a fatalError when it tries to access the StripePaymentsUI bundle, with the error unable to find bundle named Stripe_StripePaymentsUI.
The structure looks like PaymentsTests > Payments > SharedUI > StripePaymentsUI.
In previous versions of Tuist – e.g. Tuist 4.13.0, but also as recently as 4.21.2, this setup worked fine. However, in Tuist 4.22 onwards, the fatalError occurs.
If I breakpoint inside the generated Bundle accessor and po when it succeeds on Tuist 4.21.2, I get the following:
po Succeeded on "/Users/rhysmorgan/Library/Developer/Xcode/DerivedData/TuistTest-cmnvqqbbmqwjtbgyzsntlizoqtcb/Build/Products/Debug-iphonesimulator/SharedUI.framework/Stripe_StripePaymentsUI.bundle"
Opening the SharedUI.framework directory reveals that Stripe_StripePaymentsUI.bundle is indeed present.
Doing the same thing after switching to Tuist 4.22.0 and re-running the tests, I can see in the SharedUI.framework that none of the required bundles are present.
Note – the problem isn't directly related to Stripe, as the same thing happens in a different module in our real app which ultimately imports MessageKit. Also, the issue happens in Xcode 15.3 and 15.4 as well, the only other versions of Xcode I've checked.
Looking at when this bug starts happening, I wonder if it's related to this PR? https://github.com/tuist/tuist/pull/6565
How do we reproduce it?
I've determined that the bug was introduced in Tuist 4.22.0, as the below project works fine in Tuist 4.21.2 and fails in 4.22.0.
Clone the project below, and try to run the PaymentsTests' MyViewSnapshotTest.
This is a snapshot test of a view which wraps a view from Stripe's StripePaymentsUI library, which accesses a resource in the StripePaymentsUI bundle.
https://github.com/rhysm94/TuistBundleBug
Stripe is installed using SPM.
Error log
Test Suite 'Selected tests' started at 2024-10-17 12:25:57.493.
Test Suite 'PaymentsTests.xctest' started at 2024-10-17 12:25:57.494.
Test Suite 'MyViewSnapshotTests' started at 2024-10-17 12:25:57.494.
Test Case '-[PaymentsTests.MyViewSnapshotTests testMyViewSnapshot]' started.
StripePaymentsUI/TuistBundle+StripePaymentsUI.swift:37: Fatal error: unable to find bundle named Stripe_StripePaymentsUI
macOS version
15.0.1
Tuist version
4.22.0 - 4.30.0
Xcode version
16
We face the same issue.