Reputation: 4738
I have a Swift test which uses some Objective-C code that I wrote:
class ParserServiceTest: QuickSpec {
override func spec() {
var x : MyClass? // this works
x = MyClass() // this does not
}
}
When I try to build the project I get the error message:
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_MyClass", referenced from:
__TTSf4d___TTSf4g___TFC11MyProjectTests17ParserServiceTest4specfS0_FT_T_ in ParserServiceTest.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Upvotes: 3
Views: 477
Reputation: 299485
You need to include the objective-c in your test target. In your targets list, select the "...Tests" target and then the "Build Phases" pane. Look at "Compile Sources" or "Link Binary With Libraries" (depending on whether your code comes from source or a library), and make sure all the files you need are there. Most things you need to do for your executable project, you also need to do for your test project.
In the File Inspector Utility panel (right-hand panel), you can also add target membership to individual files.
Upvotes: 2