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

4

1 回答 1

1

对于 Player.h 文件,我也必须包含 .m 文件。.m 文件的代码如下,

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

@implementation Player

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

@end

它设法构建,但运行时出现错误。但是,这是另一个问题。

于 2014-11-04T01:58:52.250 回答