Nimble + Nimble-Snapshots tests failing after Tuist upgrade

What happened?

After upgrading Tuist from version 4.9.0 to 4.48.2, our unit tests that utilize Nimble + Nimble-Snapshots started failing with the following error:

Thread 1: Fatal error: Test matchers must be called from inside a test block

We integrate all external dependencies using Tuist’s dependency management system, rather than native Xcode SPM integration.

Notes:

Using native Xcode SPM integration does not exhibit this issue.

Staying on Tuist version 4.9.0 also avoids this issue.

Sample Projects:
I’ve prepared two sample projects demonstrating this issue:

One using tuist install integration

One using native Xcode SPM integration

(Include links to repositories or attach projects here.)

NimbleIssue-Tuist-Install.zip
NimbleIssue-SPM-Install.zip

How do we reproduce it?

Set up a test suite using Nimble + Nimble-Snapshots integrated via Tuist dependencies.

Run unit tests.

Expected Behavior:
Tests run successfully, as they did in Tuist 4.9.0.

Actual Behavior:
Tests fail immediately with the above error.

Error log

Thread 1: Fatal error: Test matchers must be called from inside a test block

macOS version

15.4.1

Tuist version

4.48.2

Xcode version

16.2

Hey @dogo :wave:

This does look like a valid issue. Feel free to flag a GitHub issue instead since you’ve been able to find a reproducer.

Would you be able to find the version where the regression was introduced? You can do a sort of binary search to find the first version that doesn’t work. That would help us a ton in debugging this issue.

Hi, @marekfort

I managed to isolate the issue; it starts occurring from version 4.13.0. I’m 99% sure it’s related to this PR:
Do not automatically add -ObjC flag when integrating Objective-C dependencies.

I’ll try to perform some additional tests later.

My Github issue:

@dogo could you try the troubleshooting recommendations in this page? In particular, try to add the OTHER_LDFLAGS=-ObjC to the target that imports Nimble & Nimble-Snapshots. If that doesn’t work, you can then add GENERATE_MASTER_OBJECT_FILE=YES to those targets. For that you can use PackageSettings in your Package.swift


#if TUIST
    import ProjectDescription
    import ProjectDescriptionHelpers

    let packageSettings = PackageSettings(
        targetSettings: [
            "iOSSnapshotTestCase": ["ENABLE_TESTING_SEARCH_PATHS": "YES", "GENERATE_MASTER_OBJECT_FILE": "YES"],
            "Nimble-Snapshots": ["ENABLE_TESTING_SEARCH_PATHS": "YES", "GENERATE_MASTER_OBJECT_FILE": "YES"],
            "Nimble": ["GENERATE_MASTER_OBJECT_FILE": "YES"]
        ]
    )
#endif

I can confirm that applying the .settings(base: ["OTHER_LDFLAGS": "-ObjC"]) settings to the project’s ..Tests targets fixes the issue.