Build Failed - iTahDoodle


#1

Sorry I haven’t programmed since DOS - I’m on page 185 of tricycle book - checked code over and over and can’t figure out what’s wrong - just trying to see view laid out. copy of error below. Grateful for any clues…

Ld /Users/bensheppard/Library/Developer/Xcode/DerivedData/iTahDoodle-bmrbicvjaxitdtavwhtatbgmoesg/Build/Products/Debug-iphonesimulator/iTahDoodle.app/iTahDoodle normal i386
cd /Users/bensheppard/Desktop/iTahDoodle
setenv MACOSX_DEPLOYMENT_TARGET 10.6
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/clang -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk -L/Users/bensheppard/Library/Developer/Xcode/DerivedData/iTahDoodle-bmrbicvjaxitdtavwhtatbgmoesg/Build/Products/Debug-iphonesimulator -F/Users/bensheppard/Library/Developer/Xcode/DerivedData/iTahDoodle-bmrbicvjaxitdtavwhtatbgmoesg/Build/Products/Debug-iphonesimulator -filelist /Users/bensheppard/Library/Developer/Xcode/DerivedData/iTahDoodle-bmrbicvjaxitdtavwhtatbgmoesg/Build/Intermediates/iTahDoodle.build/Debug-iphonesimulator/iTahDoodle.build/Objects-normal/i386/iTahDoodle.LinkFileList -mmacosx-version-min=10.6 -Xlinker -objc_abi_version -Xlinker 2 -fobjc-arc -Xlinker -no_implicit_dylibs -D__IPHONE_OS_VERSION_MIN_REQUIRED=50000 -framework UIKit -framework Foundation -framework CoreGraphics -o /Users/bensheppard/Library/Developer/Xcode/DerivedData/iTahDoodle-bmrbicvjaxitdtavwhtatbgmoesg/Build/Products/Debug-iphonesimulator/iTahDoodle.app/iTahDoodle

Undefined symbols for architecture i386:
"_docPath", referenced from:
-[BNRAppDelegate application:didFinishLaunchingWithOptions:] in BNRAppDelegate.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)


#2

You are missing the docPath() function. It should be implemented in BNRAppDelegate.m. And it appears in the middle of page 181 under the heading “Adding a C helper function”


#3

Thank you very much for your reply. Your book is great - would not attempt to learn Objective C without it. I did include the stuff from page 181 before - don’t know why function not being recognized code from program below.

//
// BNRAppDelegate.m
// iTahDoodle
//
// Created by Bennett Sheppard on 3/23/12.
// Copyright © 2012 MyCompanyName. All rights reserved.
//

#import “BNRAppDelegate.h”

// Helper function to fetch the path to our to-do data stored on disk
NSString *docpath()
{
NSArray *pathlist = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask, YES);
return [[pathlist objectAtIndex:0] stringByAppendingPathComponent:@“data.td”];
}

@implementation BNRAppDelegate

@synthesize window = _window;

#pragma mark - Application delegate callbacks

  • (BOOL)application:(UIApplication *)application
    didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
    //Attempt to load an existing to-do dataset from an array stored to disk.
    NSArray *plist = [NSArray arrayWithContentsOfFile:docPath()];
    if ((plist)) {
    // If there was a dataset available, copy it into our instance variable.
    tasks = [plist mutableCopy];
    } else {
    // Otherwise, just create an empty one to get us started.
    tasks = [[NSMutableArray alloc] init];
    }

    // Create and configure the UIWindow instance
    // A CGRect is a struct with an origin (x,y) and size (width,height)
    CGRect windowFrame = [[UIScreen mainScreen] bounds];
    UIWindow *theWindow = [[UIWindow alloc] initWithFrame:windowFrame];
    [self setWindow:theWindow];

    // Define the frame rectangles of the three UI elements
    // CGRectMake() creates a CGRect from (x, y, width, height)
    CGRect tableFrame = CGRectMake(0, 80, 320, 380);
    CGRect fieldFrame = CGRectMake(20, 40, 200, 31);
    CGRect buttonFrame = CGRectMake(228, 40, 72, 31);

    // Create and configure the table view
    taskTable = [[UITableView alloc] initWithFrame:tableFrame];
    [taskTable setSeparatorStyle:UITableViewCellSeparatorStyleNone];

    // Create and configure the text field where new tasks will be typed
    taskField = [[UITextField alloc] initWithFrame:fieldFrame];
    [taskField setBorderStyle:UITextBorderStyleRoundedRect];
    [taskField setPlaceholder:@“Type a task, tap Insert”];

    // Create and configure a rounded rect Insert button
    insertButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [insertButton setFrame:buttonFrame];

    // Buttons behave usig a target/action callback
    // Configure the Insert button’s action to call this object’s -addTask: method
    [insertButton addTarget:self
    action:@selector(addTask:)
    forControlEvents:UIControlEventTouchUpInside];

    // Give the button a title
    [insertButton setTitle:@"Insert"
    forState:UIControlStateNormal];

    // Add our three UI elements to the window
    [[self window] addSubview:taskTable];
    [[self window] addSubview:taskField];
    [[self window] addSubview:insertButton];

    // Finalize the window ans put it on the screen
    [[self window] setBackgroundColor:[UIColor whiteColor]];
    [[self window] makeKeyAndVisible];

    return YES;
    }

  • (void)applicationWillResignActive:(UIApplication )application
    {
    /

    Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
    */
    }

  • (void)applicationDidEnterBackground:(UIApplication )application
    {
    /

    Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
    */
    }

  • (void)applicationWillEnterForeground:(UIApplication )application
    {
    /

    Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
    */
    }

  • (void)applicationDidBecomeActive:(UIApplication )application
    {
    /

    Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
    */
    }

  • (void)applicationWillTerminate:(UIApplication )application
    {
    /

    Called when the application is about to terminate.
    Save data if appropriate.
    See also applicationDidEnterBackground:.
    */
    }

@end


#4

Got it!

docPath instead of docpath

very picky language - tougher than foxbase … ha ha


#5

Wow! I had the same problem. I typed “docpath” instead of “docPath,” and it took me an hour to figure it out. I wanted so bad to skip to the next chapter, but remembered from web programming that fixing problems is one of the best ways to learn how to program. Thank you for writing this book. It is the best way to learn this language BY FAR!