PDA

View Full Version : XCode Error ".objc_class_name_", referenced from:




Hot Sauce79
Jul 10, 2008, 08:57 AM
Here is the error that is given.

Undefined symbols:
".objc_class_name_PlacardView", referenced from:
literal-pointer@__OBJC@__cls_refs@PlacardView in MoveMe2View.o
ld: symbol(s) not found
collect2: ld returned 1 exit status


Here is the code (MoveMe2View.m) that contains the error.

#import "MoveMe2View.h"
#import "PlacardView.h"

@implementation MoveMe2View
@synthesize placardView;

- (id)initWithCoder: (NSCoder *)coder {
if (self = [self initWithCoder:coder]) {
[self setUpPlacardView];
}
return self;
}

- (void)setUpPlacardView {

PlacardView *aView = [[PlacardView alloc] init]; //I tracked the error
self.placardView = aView; //down to these three
[aView release]; //lines of code

placardView.center = self.center;
[self addSubview: placardView];
}


- (void)dealloc {
[placardView release];
[super dealloc];
}

@end

Here is the PlacardView.h

#import <UIKit/UIKit.h>


@interface PlacardView : UIView {
UIImage *placardImage;
}
@property (nonatomic, retain) UIImage *placardImage;
@end



Any and all help will be greatly appreciated. Thank you.



lee1210
Jul 10, 2008, 09:11 AM
Where's the implementation of PlacardView? You included the header file, but not the source that contains the actual definitions.

-Lee

Hot Sauce79
Jul 10, 2008, 09:22 AM
here is the implementation and the whole PlacardView.m

#import "PlacardView.h"


@implementation PlacardView
@synthesize placardImage;

- (id)init {
UIImage *image = [UIImage imageNamed:@"Placard.png"];
CGRect frame = CGRectMake(0, 0, image.size.width, image.size.height);

if (self = [super initWithFrame:frame]) {
self.opaque = NO;
placardImage = image;
}
return self;
}


- (void)dealloc {
[placardImage release];
[super dealloc];
}


- (void)drawRect: (CGRect)rect {
// Drawing code
[placardImage drawAtPoint: (CGPointMake(0.0,0.0))];

}

Also here is the MoveMe2View.h code

#import <UIKit/UIKit.h>

@class PlacardView;

@interface MoveMe2View : UIView {
PlacardView *placardView;
}
@property (nonatomic, retain) PlacardView *placardView;

- (void)setUpPlacardView;

@end

Hot Sauce79
Jul 10, 2008, 11:48 AM
Still havent gotten it yet. Any help or words of advice are good.

Hot Sauce79
Jul 10, 2008, 01:06 PM
I figured out what was wrong. When i added the file I had forgotten to click on the check box for the compiler to know its ready to be compiled. I also had to run the Clean function under the Build section in the menu. Everything works now.

ecume
Sep 2, 2008, 01:32 PM
that error just means that the compiler can't find that class or object. You probably need to add a framework...

Soulstorm
Sep 3, 2008, 03:37 AM
That has happened to me a lot of times. That error is caused when the compiler can't find a class or function. Besides the obvious reasons for that to happen, you should also do something like this:

On the left of the Xcode window go to the targets, and find your application. Open it. You should see a build phase named "Compile Sources". Make sure that your implementation file is included inside that build phase. If not, drag and drop it onto that build phase.

Also, make sure that you have all frameworks included and linked to your application! To make that sure, go into your application target again, and see the "Link Binary With Libraries" build phase. See if all necessary .framework files are in there. If not, add them using drag and drop.

I hope this solves your problem.

awnispel
Aug 2, 2010, 05:56 PM
A belated thanks to Soulstorm for fixing similar bug to that posted :)