I'm converting an Objective-C app to Swift and using the existing Objective-C unit tests to confirm the changes are working properly.
I replaced a couple of Objective-C app files with Swift and did the following:
- added "@objc class" where needed (in addition to inheriting from an Objective-C class),
- targeted the Swift files to both MyApp and MyAppTest targets,
- set "Enable Testability Yes" (Debug only) for both targets.
- In the unit test files I added #import "MyAppTests-Swift.h" and removed the #import "MyObjcClass.h".
- I also removed "MyObjcClass.m" from the build phase compile sources list.
Xcode generates the "MyAppTests-Swift.h" file. Examining the generated file (cmd-click), reveals the usual mass of Swift specific #if #defines that precedes where my Swift classes should be located but aren't.
The app will build and run fine with the replacement Swift files. There are other Objective-C files in the app which import "MyApp-Swift.h in order to use my Swift classes." The MyApp-Swift.h" file contains the usual mass of Swift specific #if #defines and my Swift classes from the Swift app files.
Xcode generates "-Swift.h" files for both targets. For some reason, however, the one for the Tests target doesn't receive the Swift class information while the one for the app target does. So it's not an issue of using a feature specific to Swift but not Objective-C.
I've eliminated all compile errors, built from clean but still not working.
Any suggestions?
I'm using XC7 (7C68) iOS 9.1