I have a strange problem where doing a
@testable import of a module produces "undefined identifier" errors. Unfortunately, I haven't been able to reproduce in a simple enough project that I could share. I'm looking for debugging ideas in order to understand what's happening and maybe come up with a workaround.
I have module
A that is tested by module
B. I build
A as a statically linked framework, and it includes a mix of Objective-C and Swift. When in
B I do
@testable import A, and try to use a class declared in one of the Swift source files from
A, I get "undefined identifier". I an passing the
-enable-testing flag to Swift for both
What is strange, is that if I move the
@testable import A to the beginning of the file (before other
swiftc compiles it successfully. I have found more problems compiling tests like these and moving the
@testable import's to the start of the file doesn't always fix the problem. Sometimes adding
import A before
@testable import A fixes it, sometimes it doesn't.
This is with Xcode 10.3 but I can reproduce with Open Source Swift as of the
swift-5.0.1-RELEASE tag. I've also added some debugging around module loading and symbol table lookups but so far haven't found much (this is what gave me the idea of re-ordering the
One thing to note is that I'm building with Bazel. If I build the same project with
xcodebuild then it works. I've compared the Xcode and Bazel built frameworks and can't figure out what the difference might be. It all looks correct.
Any ideas how to further debug this problem?