3

I have a mixed objective-c and Swift project and I try to write Unit tests for it. My project name is: Alphaproject my product module name is: Alphaproject I set to YES Defines Module in my main Target (Alphaproject) and set to YES EnableTestability for Debug only in this same Target.

In my Test class, I try to import my product module name:

@testable import Alphaproject

Additional notes:

  • all my projects files are only part of the main target
  • my test files are only part of the test target
  • My scheme for Test is set to Build Debug configuration.
  • I also tried to clean the Build folder (ALT + Clean)
  • The project doesn't have any error when compiling or trying to run tests except this "No such module Alphaproject"

Any other ideas?

Mikael
  • 2,355
  • 1
  • 21
  • 45
  • I was having this same issue, but the problem was resolved after going to Build Settings and setting "Defines Modules" = YES under the main main target and testing target. – Parrett Apps Feb 02 '18 at 12:34

2 Answers2

7

OK! The problem was coming from the fact that I had arm64 in my Debug configuration for Valid Architectures. As the main target also doesn't contain arm64 in Valid Architectures, It couldn't apparently find the module... I think apple can make better work on displaying a proper error here. (Apple, if you read me, please)

enter image description here

Mikael
  • 2,355
  • 1
  • 21
  • 45
1

In my case, the initial Xcode project was Objective-C, and I added testing targets that were Swift-based, and the import <Product Moodule Name> failed. I ensured that Defines Module was set to YES in Build Settings, but still got the error as indicated. The fix for me was to add a Bridging Header into the Objective-C main project.

Chris Prince
  • 7,288
  • 2
  • 48
  • 66