2

Hello Everyone,

[Error: 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)] 

I am running an application which will produce sound after button is clicked ,

I have included all the framework for audio after seeing the error

 [ 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)
        ]

from stack overflow but still its not working for me .. please look at the below code i have included my .h and .m file and suggest me some solution

It May be an linker error but i have included the framework from build phase and included #import framework ..Please check out my below Code if i am missing something please let me know ... I am self learning beginner for iPhone Development ..

        //  ViewController.h



        //  Audioplaying
        //
        //  Created by Vaibhav on 12/31/12.
        //  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
        //

        #import <UIKit/UIKit.h>
        #import <AVFoundation/AVAudioPlayer.h>
         #import <AudioToolbox/AudioToolbox.h>


        @interface ViewController : UIViewController <AVAudioPlayerDelegate >

        {
            AVAudioPlayer *player;
            UIButton *playButton;
        }

        @property (nonatomic, retain) AVAudioPlayer *player;
        @property (nonatomic, retain) IBOutlet UIButton *playButton;

        - (IBAction) play;

        @end


    //
    //  ViewController.m
    // 
    #import "ViewController.h"
    #import <AVFoundation/AVAudioPlayer.h>

    @implementation ViewController

    @synthesize player, playButton;


    - (void)viewDidLoad {

        // grab the path to the caf file
        NSString *soundFilePath =
        [[NSBundle mainBundle] pathForResource: @"blip"
                                        ofType: @"caf"];

        NSURL *fileURL = [[NSURL alloc] initFileURLWithPath: soundFilePath];

        // create a new AVAudioPlayer initialized with the URL to the file
        AVAudioPlayer *newPlayer =
        [[AVAudioPlayer alloc] initWithContentsOfURL:fileURL error:nil];


        // set our ivar equal to the new player
        self.player = newPlayer;


        // preloads buffers, gets ready to play
        [player prepareToPlay];
        // set delegate so we can get called back when the sound has finished playing
        [player setDelegate: self];

        [super viewDidLoad];
    }

    // delegate method
    - (void) audioPlayerDidFinishPlaying: (AVAudioPlayer *) player
                            successfully: (BOOL) completed {
        if (completed == YES) {
            self.playButton.enabled = YES;
        }
    }


    // 
    - (IBAction) play {

        self.playButton.enabled = NO;
        [self.player play];

    }
    - (void)viewDidUnload
    {
        [super viewDidUnload];
        // Release any retained subviews of the main view.
        // e.g. self.myOutlet = nil;
    }

    - (void)viewWillAppear:(BOOL)animated
    {
        [super viewWillAppear:animated];
    }

    - (void)viewDidAppear:(BOOL)animated
    {
        [super viewDidAppear:animated];
    }

    - (void)viewWillDisappear:(BOOL)animated
    {
        [super viewWillDisappear:animated];
    }

    - (void)viewDidDisappear:(BOOL)animated
    {
        [super viewDidDisappear:animated];
    }

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
        // Return YES for supported orientations
        return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
    }

    @end

Error :

Build target Audioplaying

Ld /Users/vaibhav/Library/Developer/Xcode/DerivedData/Audioplaying-eaaytfuwbstsyffgakkifipcygeu/Build/Products/Debug-iphonesimulator/Audioplaying.app/Audioplaying normal i386
    cd "/Users/vaibhav/Iphone projects/Audioplaying"
    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/vaibhav/Library/Developer/Xcode/DerivedData/Audioplaying-eaaytfuwbstsyffgakkifipcygeu/Build/Products/Debug-iphonesimulator -F/Users/vaibhav/Library/Developer/Xcode/DerivedData/Audioplaying-eaaytfuwbstsyffgakkifipcygeu/Build/Products/Debug-iphonesimulator "-F/Users/vaibhav/Iphone projects/Audioplaying" -filelist /Users/vaibhav/Library/Developer/Xcode/DerivedData/Audioplaying-eaaytfuwbstsyffgakkifipcygeu/Build/Intermediates/Audioplaying.build/Debug-iphonesimulator/Audioplaying.build/Objects-normal/i386/Audioplaying.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 AVFoundation -framework UIKit -framework Foundation -framework CoreGraphics -o /Users/vaibhav/Library/Developer/Xcode/DerivedData/Audioplaying-eaaytfuwbstsyffgakkifipcygeu/Build/Products/Debug-iphonesimulator/Audioplaying.app/Audioplaying

ld: warning: ignoring file /Users/vaibhav/Iphone projects/Audioplaying/AVFoundation.framework/AVFoundation, file was built for unsupported file format which is not the architecture being linked (i386)
Undefined symbols for architecture i386:
  "_OBJC_CLASS_$_AVAudioPlayer", 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)
jtbandes
  • 115,675
  • 35
  • 233
  • 266
krish
  • 641
  • 3
  • 9
  • 26
  • It is very difficult to understand what your actual error message is, because you have mixed it together with your comments and you have left out part of the error. Choose View > Navigators > Show Log Navigator from the menu bar. Click on your build log in the navigator. Find the failed link command. Right-click the failed link command and choose “Copy Transcript for Shown Results (All, All Messages) as Text”. Edit your post and paste in what you copied. Do **not** try to put it in a comment. – rob mayoff Jan 02 '13 at 04:55
  • @rob: Error Message Has been added have a look at it... – krish Jan 02 '13 at 05:12

2 Answers2

6

Just add Foundation.framework and AVFoundation.framework framework from Build Phases=>Link Binaries With Libraries and just try it.

Paras Joshi
  • 20,427
  • 11
  • 57
  • 70
  • @krish i just forgot to write the AVFoundation framework in the answer dude.. but now just add this and check that and also you add UIKit framework?? – Paras Joshi Jan 02 '13 at 05:35
  • These are the framework included : AVFoundation.framework/ UIKit.framework/ Foundation.framework/ fCoreGraphics.framework/ – krish Jan 02 '13 at 05:41
  • ok this is the error for framework that i am sure , ok now add CoreMedia framework try it – Paras Joshi Jan 02 '13 at 05:48
  • oh dude i just add these frameworks and yes also i added at that time and it worked dude – Paras Joshi Jan 02 '13 at 06:04
  • @krish also import this 3 class like #import #import #import – Paras Joshi Jan 02 '13 at 06:05
  • I have included , please check out the error .. "_OBJC_CLASS_$_AVAudioPlayer", 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) – krish Jan 02 '13 at 06:11
  • see this link @krish http://stackoverflow.com/questions/6984368/undefined-symbols-for-architecture-i386-objc-class-skpsmtpmessage-refere here sometime xcode not add .m for compile source so it happens.. just see the answer from that – Paras Joshi Jan 02 '13 at 06:14
  • Here is the list of files in compiler source main.m AppDelegate.m ViewController.m – krish Jan 02 '13 at 06:26
  • and if you run this application in device then just remove this application from your device and then again run it... – Paras Joshi Jan 02 '13 at 06:48
  • ok then just reset it... bcoz some times it happen with old crashed file are exist in user bin so its happen ... first reset it from iOS Simulator and click on it and click again on Reset contetnt and settings option.. – Paras Joshi Jan 02 '13 at 06:53
  • Yes its working , i dragged the framework directly in my framework folder thn it worked .. thanks and if you have any tutorial on consuming web service please tell me .. – krish Jan 04 '13 at 11:20
0

You have somehow created your own broken framework named AVFoundation.framework inside your project. The presence of this broken framework is preventing the linker from using the system's AVFoundation framework.

You need to delete /Users/vaibhav/Iphone projects/Audioplaying/AVFoundation.framework and everything in it.

rob mayoff
  • 375,296
  • 67
  • 796
  • 848