首页 > 其他 > 详细

Undefined symbols for architecture i386: "_OBJC_CLASS_$_XX" 错误解决方法

时间:2014-03-20 18:30:46      阅读:581      评论:0      收藏:0      [点我收藏+]

以下是我在一个工程中的类似操作带来的错误,现在将其简化。

首先新建一个工程,再新建一个Target:bubuko.com,布布扣

不计单元测试部分的话,现在工程中有两个Target:Demo和ATarget。

在Demo的ViewController中添加一个类方法并公开接口:

+ (void)logClassName {
    NSLog(@"%@", [self class]);
}

在ATarget的AppDelegate中调用该方法:

#import "ViewController.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [ViewController logClassName];
    
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    return YES;
}

选中ATarget对应的Scheme,Command + R

bubuko.com,布布扣

报错:

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

原因:在ATarget中找不到ViewController这个类。

解决方法:打开ATarget的Build Phases,在Compile Sources中添加ViewController.m文件bubuko.com,布布扣


重新运行,无错通过。


出现Undefined symbols for architecture i386:   "_OBJC_CLASS_$_XX"的错误,原因通常在于无法识别的标记所在的类文件没有被加入到Compile Sources中。


Undefined symbols for architecture i386: "_OBJC_CLASS_$_XX" 错误解决方法,布布扣,bubuko.com

Undefined symbols for architecture i386: "_OBJC_CLASS_$_XX" 错误解决方法

原文:http://blog.csdn.net/jymn_chen/article/details/21614881

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!