Apple Mach-O链接器错误,架构x86_64的未定义符号

时间:2014-11-03 09:50:24

标签: ios8 osx-yosemite xcode6.1

我刚刚开始iOS编程,我正在尝试编译一个简单的代码,但我无法这样做。我收到的错误信息是,

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)

现在,我发现了两个类似的问题(herehere)使用与我相同的环境进行编码并面临类似的问题。我尝试了他们的解决方案但是没有成功。

当我刚刚启动iOS时,我使用此tutorial作为指南,并尝试运行他们的代码。错误发生在我为播放器变量赋值的部分。代码如下。

#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;
}

我的架构设置如下, ArchitectureSettings

Player.h和PlayersViewController.h的代码与教程中的代码完全相同。

更新

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

我的构建结果 BuildResults

1 个答案:

答案 0 :(得分:1)

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

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

@implementation Player

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

@end

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