1

编辑 我的问题是我没有将课程链接到我的项目。

我正在开发一个基本上是终端应用程序的应用程序。当我尝试构建它时,我遇到了构建错误。

    Ld /Users/evanstoddard/Library/Developer/Xcode/DerivedData/Highjack-anstcjvykrnniwbltvijvyvexirq/Build/Products/Debug-iphonesimulator/Highjack.app/Highjack normal i386
    cd /Users/evanstoddard/Desktop/Highjack
    setenv IPHONEOS_DEPLOYMENT_TARGET 6.0
    setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.0.sdk -L/Users/evanstoddard/Library/Developer/Xcode/DerivedData/Highjack-anstcjvykrnniwbltvijvyvexirq/Build/Products/Debug-iphonesimulator -F/Users/evanstoddard/Library/Developer/Xcode/DerivedData/Highjack-anstcjvykrnniwbltvijvyvexirq/Build/Products/Debug-iphonesimulator -filelist /Users/evanstoddard/Library/Developer/Xcode/DerivedData/Highjack-anstcjvykrnniwbltvijvyvexirq/Build/Intermediates/Highjack.build/Debug-iphonesimulator/Highjack.build/Objects-normal/i386/Highjack.LinkFileList -Xlinker -objc_abi_version -Xlinker 2 -fobjc-arc -fobjc-link-runtime -Xlinker -no_implicit_dylibs -mios-simulator-version-min=6.0 -framework UIKit -framework Foundation -framework CoreGraphics -o /Users/evanstoddard/Library/Developer/Xcode/DerivedData/Highjack-anstcjvykrnniwbltvijvyvexirq/Build/Products/Debug-iphonesimulator/Highjack.app/Highjack

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

这是我的实现文件:

    //
//  ViewController.m
//  My Utility 2
//
//  Created by Evan Stoddard on 2/6/13.
//  Copyright (c) 2013 Evan Stoddard. All rights reserved.
//

#import "ViewController.h"
#import "XXFdHijacker.h"

@interface ViewController () <XXFdHijackerDelegate>
@property (weak, nonatomic) IBOutlet UITextView *loggingView;

@property (strong, nonatomic) XXFdHijacker *stdoutHijacker;
@property (strong, nonatomic) XXFdHijacker *stderrHijacker;

@property (strong, nonatomic) NSMutableString *contents;

@end // extension


@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Hijack standard out.
    self.stdoutHijacker = [XXFdHijacker hijackerWithFd: fileno(stdout)];
    setbuf (stdout, NULL);
    self.stdoutHijacker.delegate = self;
    [self.stdoutHijacker startHijacking];
    [self.stdoutHijacker startReplicating];

    // Hijack standard error
    self.stderrHijacker = [XXFdHijacker hijackerWithFd: fileno(stderr)];
    setbuf (stderr, NULL);
    self.stderrHijacker.delegate = self;
    [self.stderrHijacker startHijacking];
    [self.stderrHijacker startReplicating];

    self.contents = [NSMutableString string];

    NSLog (@"All Kids Love Log");

} // viewDidLoad

- (void) scrollToEnd {
    NSRange range = NSMakeRange (self.contents.length, 0);
    [self.loggingView scrollRangeToVisible: range];
} // scrollToEnd


- (void) hijacker: (XXFdHijacker *) hijacker  gotText: (NSString *) text {
    if (hijacker == self.stdoutHijacker) [self.contents appendString: @"stdout: "];
    if (hijacker == self.stderrHijacker) [self.contents appendString: @"stderr: "];

    [self.contents appendString: text];
    self.loggingView.text = self.contents;
    [self scrollToEnd];
} // hijacker

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

如果您需要查看更多内容,我愿意发送我的 xcode 项目。

4

1 回答 1

2

检查 Xcode 项目中的 XXFdHijacker.m 文件,打开“Utilities”视图(Xcode 的右侧面板)并确保为您的应用选中了“Target Membership”复选框。它可能没有被编译,因此在尝试链接时缺少符号

于 2013-02-07T00:47:23.393 回答