I have some constant strings defined as extern const in header of MyClass.h:
extern NSString * const myConstant;
and in .m file:
NSString * const myConstant = @"Some Constant";
And I have a unit test file testing MyClass
, it could test the class but when I use the constant in the unit test, the linker has a problem:
Undefined symbols for architecture x86_64:
"_myConstant", referenced from: ...
MyClass.m isn't ticked to be part of the Tests target, but I have the "bundler loader" and "test host" set up in Build Settings, so I thought I don't need to have MyClass.m part of Tests target, which works fine for the class itself.
Is there anything I did wrong with the extern const
that it can't be found by the tests?