Im trying to test some Swift class (@objc class) in my legacy Objc code. I am importing "UnitTests-Swift.h" in my test classes.
Then I get this error:
Module "MyApp" not found in the autogenerated "UnitTests-Swift.h"
This is whats inside the top part of the "UnitTests-Swift.h"
typedef int swift_int3 __attribute__((__ext_vector_type__(3)));
typedef int swift_int4 __attribute__((__ext_vector_type__(4)));
#if defined(__has_feature) && __has_feature(modules)
@import XCTest;
@import ObjectiveC;
@import MyApp;
@import CoreData;
#endif
I cleaned the project, checked all the relevant flags ("No such module" when using @testable in Xcode Unit tests, Can't use Swift classes inside Objective-C), removed derived data and so on.. No idea of whats happening, but I m quite sure that @import MyApp shouldnt be there..
Can anyone help me with this?
Just got this issue in my project and after the entire day spent on investigation I finally resolved it. Basically this happens because you have cyclic dependency between ObjC and Swift. So in my case it was:
@obj
attribute in a main target;UnitTestTarget-Swift.h
in any Objective-C class of your UnitTest targetSo fairly simple combination leads to this error. In order to fix this you want either:
private
, so it won't get to UnitTestTarget-Swift.h
or
@objc
, which will allow you to access your SwiftClass from all ObjectiveC test classes, but those classes won't have any idea about the Swift Protocol.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With