0

i just started iOS programming and am trying to compile a simple code but am unable to do so. The error messages i received are,

Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_Player", referenced from:
  objc-class-ref in AppDelegate.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Now, i have found 2 similar questions (here and here) that are using the same environment as i am to code and are facing similar issues as i am too. I have tried their solutions but am unsuccessful.

As i just started iOS, i was using this tutorial as a guide and am trying to run their code. The error occurs at the part where i assign some value to the player variable. Code are as follows.

#import "AppDelegate.h"
#import "Player.h"
#import "PlayersViewController.h"

@interface AppDelegate ()

@end

@implementation AppDelegate{
    NSMutableArray *_players;
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary        *)launchOptions {
    // Override point for customization after application launch.
    _players = [NSMutableArray arrayWithCapacity:20];

    Player *player = [[Player alloc] init];
    player.name = @"Bill Evans"; //error will occur here

    return YES;
}

My Architecture settings are as follows, ArchitectureSettings

The code for the Player.h and PlayersViewController.h are exactly the same with those from the tutorial.

Update

Player.h

@interface Player : NSObject

@property (nonatomic, copy) NSString *name;
@property (nonatomic, copy) NSString *game;
@property (nonatomic, assign) int rating;

@end

PlayersViewController.h

#import <UIKit/UIKit.h>

@interface PlayersViewController : UITableViewController

@property (nonatomic, strong) NSMutableArray *players;

@end

My build results BuildResults

Community
  • 1
  • 1
winhung
  • 553
  • 1
  • 5
  • 19
  • 2
    Sounds like you haven't added the source file containing the `Player` class to the Xcode target. Check the build logs and see if it's being compiled. – trojanfoe Nov 03 '14 at 09:53
  • Does that mean a .m file for Player needs to be included as well ? I followed the tutorial and all they mentioned were the .h files. I will update my question with the contents of the .h files. – winhung Nov 04 '14 at 00:54
  • So, as embarrassing as it is, it really does seem i need to include a .m file and specify the '@sysnthesize' syntax for those variables that i declared with the '@property' syntax. – winhung Nov 04 '14 at 01:56

1 Answers1

1

With the Player.h file, i had to include the .m file for it too. The code for the .m file are as follows,

#import <Foundation/Foundation.h>
#import "Player.h"

@implementation Player

@synthesize name = _name;
@synthesize game = _game;

@end

It manages to build but there are errors when running. However, that is for another question.

winhung
  • 553
  • 1
  • 5
  • 19