I'm trying to do the same with the tutorials, but I don't know why it always gives me this wrong result. However, when I install Apple's code, it runs well.
Yes, in Xcode, each file can be associated with one or more targets through the “Target Membership” section. For your tests to have access to the necessary classes, you must check the box for the test targets you want the file to be a part of.
You can also specify the targets at the moment you create the file, like this: