Reputation: 6268
My Problem
I getting "_OBJC_CLASS_$..., referenced from:" linker error when compiling some Xcode projects (it happens in both iOS and Mac projects) I have correctly linked frameworks and imports.
Setup
On compile I get the following linker errors: "_OBJC_CLASS_$_JGCountdownTimer", referenced from: objc-class-ref in JGCountdownTimerTestCase.o
for many classes that are used in tests.
What I've Tried
Upvotes: 10
Views: 31055
Reputation: 297
Compile doesn't include those copied files in its compile list. To fix this error select the file or folder, then go to the Build Phases panel and open the Compile Sources step, then click the + button and add them all file or folder.
Right click on a project folder, click "Add Files to ...", select the file(s), click the Options button and select the target, then click Add.
Upvotes: 0
Reputation: 10095
I faced a similar problem. I got the linker error:
_OBJC_CLASS_$_MyClass
The problem was that I had declared an @interface
for MyClass
but had not declared its corresponding @implementation
.
The fix was to simply add
@implementation MyClass
@end
Upvotes: 15
Reputation: 6268
Quick Answer
Copy and paste the following line into your build settings:
GCC_SYMBOLS_PRIVATE_EXTERN = NO
In the target build settings look for "Symbols Hidden by Default". For the Debug configuration you want "No".
I've had this problem on and off for many months and I've just discovered why.
Upvotes: 12
Reputation: 16022
Not sure if this could be the problem, but with the new compiler, any obj-c that aren't explicitly referred to/invoked will not be linked from libraries. This causes problems when you implement categories in libraries for example.
Try adding '-ObjC' to 'additional linker flags' in the build settings panel for your target. shrug
Upvotes: 2