Unit Test for Multiplatform App on Big Sur

How do I do unit test with multiplatform app?

I created a new project and add a class with one object.

Code Block swift
class MyClass {
  static var apples: [Int] = [1,2,3]
}

When I want to do unit test, it fails ...
Code Block
import XCTest
@testable import MyApp
class Tests_macOS: XCTestCase {
func testExample() throws {
XCTAssertEqual(MyClass.apples.count, 3)
}
}

Errors
Code Block python
Undefined symbols for architecture x86_64:
 "MyApp.MyClass.apples.unsafeMutableAddressor : [Swift.String]", referenced from:
   implicit closure #1 () throws -> Swift.Int in Tests_macOS.Tests_macOS.testExample() throws -> () in Tests_macOS.o
 "type metadata accessor for MyApp.MyClass", referenced from:
   implicit closure #1 () throws -> Swift.Int in Tests_macOS.Tests_macOS.testExample() throws -> () in Tests_macOS.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
-------------------------------------------------
Undefined symbol: MyApp.MyClass.apples.unsafeMutableAddressor : [Swift.String]
Undefined symbol: type metadata accessor for MyApp.MyClass

Answered by Developer Tools Engineer in 643368022
Unfortunately this isn't obvious, but the default test target type for multiplatform projects is a UI test target. UI tests don't support @testable import. If you want to run unit tests you need to add a unit test target first.
Accepted Answer
Unfortunately this isn't obvious, but the default test target type for multiplatform projects is a UI test target. UI tests don't support @testable import. If you want to run unit tests you need to add a unit test target first.
How can you tell what the target is for a test? I have two XCTestCase classs, one with this problem, one without
Unit Test for Multiplatform App on Big Sur
 
 
Q