XCode链接构建错误

时间:2009-07-27 23:55:30

标签: cocoa cocoa-touch xcode

这个对我来说是新的。甚至不确定RootViewController.o是什么?虽然这个项目确实有一个 .m &的·H 即可。构建模拟器3.0。在构建之前清除(Shift-⌘-K)。

最近在另一个同时拥有RootViewController的项目中添加了一些类......但是我没有将旧文件转移过来。从那时起就没有建成。这可能是问题的一部分吗?!?

使用配置“调试”构建项目“MyApp”的目标“MyApp” - (1个错误)

    cd "/Volumes/MacHD/Development/iPhone/MyApp"
    setenv MACOSX_DEPLOYMENT_TARGET 10.5
    setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk -L/Volumes/MacHD/Development/iPhone/MyApp/build/Debug-iphonesimulator -F/Volumes/MacHD/Development/iPhone/MyApp/build/Debug-iphonesimulator -filelist /Volumes/MacHD/Development/iPhone/MyApp/build/MyApp.build/Debug-iphonesimulator/MyApp.build/Objects-normal/i386/MyApp.LinkFileList -mmacosx-version-min=10.5 -framework Foundation -framework UIKit -framework CoreGraphics -framework AddressBook -framework AddressBookUI -o /Volumes/MacHD/Development/iPhone/MyApp/build/Debug-iphonesimulator/MyApp.app/MyApp
Undefined symbols:
  ".objc_class_name_MyViewController", referenced from:
      literal-pointer@__OBJC@__cls_refs@MyViewController in RootViewController.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

构建失败(1个错误)


编辑:清除所有目标...仍然无法构建。这是我的#includes:

RootViewController.h

#import <UIKit/UIKit.h>
#import "MyViewController.h" //tried with this and as @class MyViewController

@class AddViewController, EditingViewController;

@interface RootViewController : UITableViewController <UITableViewDelegate, UITableViewDataSource> {
    MyViewController *myVC;
    UINavigationController *navController;
    AddViewController *addViewController;
    NSArray *keys;
    NSNumberFormatter *currencyFormatter;
}

RootViewController.m:

#import "RootViewController.h"
#import "MyAppDelegate.h"
#import "MyViewController.h"
#import "AddViewController.h" 
#import "EditingViewController.h"
#import "MyObject.h"
#import "ViewCell.h"
#import "AppColors.h"
#import "CustomCellBackgroundView.h"

// Manage the editing view controller from this class so it can be easily accessed from both the detail and add controllers.
static EditingViewController *__editingViewController = nil;

@implementation RootViewController

4 个答案:

答案 0 :(得分:2)

RootViewController.m在MyViewController的某个地方有一个引用,但是你没有在文件中链接@implementation MyViewController。 RootViewController.o是通过编译RootViewController.m创建的目标文件。

答案 1 :(得分:1)

在构建之前尝试清理所有目标。如果这不起作用,请发布RootViewController.h和.m的代码,尤其是#includes。 .o扩展名是指编译器创建的目标文件。

答案 2 :(得分:1)

还有另一件事要做:选择“Classes”组时,请检入文件列表。必须启用 .m 文件旁边的复选框(告诉XCode编译并链接文件),尤其是如果您使用“添加现有文件...”命令添加它们。

答案 3 :(得分:0)

我有这个问题。答案是在其中一个答案的评论中: 选择“类”组并确保在“目标”列中选中所有.m文件复选框