evan.stoddard
evan.stoddard

Reputation: 698

I keep getting an arc error when building

EDIT My problem was that I didn't link a class to my project.

I am working on an app that is basically a terminal app. When I try to build it I'm getting a build error.

    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)

Here is my implementation file:

    //
//  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

I'm willing to send my xcode project if you need to see more.

Upvotes: 1

Views: 137

Answers (1)

Chris McGrath
Chris McGrath

Reputation: 1936

Check the XXFdHijacker.m file in your Xcode project, open the "Utilities" view (the right-hand panel of Xcode) and make sure that the "Target Membership" checkbox is checked for your app. It may not be being compiled, hence the missing symbol when trying to link

Upvotes: 2

Related Questions