簡體   English   中英

XCode鏈接構建錯誤

[英]XCode Linking build error

這是我的新手。 甚至不確定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

RootViewController.m在其中某個地方引用了MyViewController,但是您沒有在其中鏈接有@implementation MyViewController的文件。 RootViewController.o是通過編譯RootViewController.m創建的目標文件。

嘗試在構建之前清潔所有目標。 如果這不起作用,請發布RootViewController.h和.m的代碼,尤其是#includes。 .o擴展名是指由編譯器創建的目標文件。

還有另一件事要做:選擇“ Classes”組時,檢查文件列表。 必須啟用.m文件旁邊的復選框(告訴XCode編譯和鏈接文件),特別是如果您使用“添加現有文件...”命令添加它們。

我有這個問題。 答案是對以下答案之一的評論:選擇“類”組,並確保在“目標”列中選中所有.m文件復選框。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM