Xcode 12 unit test linker issue for universal app

If I create an universal project using Xcode 12 and try to import any class/struct contains a property with Date type, the test target will failed to build due to linker error when User is referenced in the test.

Code Block Swift
func testUser() {
let user: User?
}



Some part of the error
Code Block
Undefined symbols for architecture x86_64:
"nominal type descriptor for test.User in UserTests.o"
"type metadata accessor for test.User" ...


The user class looks like this:

Code Block Swift
struct User {
let id: String
let createdAt: Date
}

If I remove the createdAt: Date from the User, the build passes without any issue.

Also tested the same setup with standard iOS app using SwiftUI and SiwftUI app lifecycle, works as expected.

So looks like an issue for Universal app project.


Same here.

Hackaround: Add the files you need in your tests to the Target Membership of the test target.
Xcode 12 unit test linker issue for universal app
 
 
Q