Known bug? Cannot assign value of type 'X' to type 'X'

I'm running into a compile-time error "Cannot assign value of type 'X' to type 'X'" where X is a class I subclassed from NSObject.

Is this a known Swift compiler bug? The error message doesn't make sense to me. It happens in both Xcode 7.1 and 7.2.

Replies

Ah, it seems like this is only happening in my unit tests. I can perform the assignment just fine in my application code.


Perhaps a problem with @testable import?

Hi,


Did you ever solve this? I'm getting the same problem with my unit tests too.

Ok, The problem was that I was importing my project into my test project with: @testable import myProject, but I ALSO had the source file in the Target membership for the test project. It seems, it's mutually exclusive.


I just removed the source file from the target membership of the test projects and now just use @testable.