Error 'isolated' parameter type 'Actor?' does not conform to 'Actor' or 'DistributedActor'

I'm having a strange experience using Testing framework in Xcode 16.3.

When I use @testable import iOS_AppName I'm getting the error below in the method and when I remove it the build works fine.


Showing All Errors Only
/var/folders/dr/xxmgy3xd1pb4ml_4c73_s78r0000gn/T/swift-generated-sources/@__swiftmacro_17iOS_AppNameTests7AppTestV8testName0F0fMp_.swift:3:90: 'any' has no effect on concrete type 'Actor'

/var/folders/dr/xxmgy3xd1pb4ml_4c73_s78r0000gn/T/swift-generated-sources/@__swiftmacro_17iOS_AppNameTests7AppTestV8testName0F0fMp_.swift:3:80: 'isolated' parameter type 'Actor?' does not conform to 'Actor' or 'DistributedActor'

I can only run the tests with @testable import iOS_AppName by adding @MainActor or async to the method.

Also in Xcode 16.2 I have no problem.

My test code:

@testable import iOS_AppName
import Testing

class AppClass { // This class is in the app's target, I left it here just to make it visible
    var name = "Swift"
}

struct AppTest {

    @Test
    func testName() {
        let appClass = AppClass()

        #expect(appClass.name == "Swift")
    }
}

Does anyone know if there is any configuration in the project that I can do to solve this?
This error is very strange and I would like your opinion before I add async to all the tests.

1 Like

Do you have a type in your app module named Actor? I can't seem to reproduce this in a small example project, perhaps because something in your app module (not shown in this snippet) is causing the error.

3 Likes

Oh, I think I see the issue in Swift Testing's code. Can you please file a GitHub issue in the swift-testing repo?

lol you did it!

There was a class named Actor in the application, I updated it and now I can run the test build :folded_hands:

Maybe some change added to the 6.1 testing framework conflicted this.
I spent half my work day yesterday trying to figure it out :sleepy_face:

Thank you @smontgomery!

3 Likes

I’m working on a bug fix in swift-testing for this. It should be possible to have a type with that name in your own code, if you wish.

3 Likes

Here's the fix:

3 Likes