Iphone 链接器错误OBJC“U类”“U$”AVAudioPlayer“;

Iphone 链接器错误OBJC“U类”“U$”AVAudioPlayer“;,iphone,xcode4.2,Iphone,Xcode4.2,各位好, [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

各位好,

[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 ,
在看到错误后,我已经包含了所有音频框架

 [ 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)
        ]
从堆栈溢出,但它仍然不为我工作。。请看下面的代码,我已经包括了我的.h和.m文件,并建议我一些解决方案

这可能是一个链接器错误,但我已经包含了构建阶段的框架和 #导入框架..请检查我下面的代码,如果我缺少什么,请让我知道。。。我是iPhone开发的自学初学者

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

只需添加
Foundation.framework
AVFoundation.framework
framework from
Build Phases=>将二进制文件与库链接起来就可以了。

您已经在项目中创建了自己的名为
AVFoundation.framework
的破框架。存在此已损坏的框架会阻止链接器使用系统的
AVFoundation
框架


您需要删除
/Users/vaibhav/Iphone projects/Audioplaying/AVFoundation.framework
以及其中的所有内容。

很难理解您的实际错误消息是什么,因为您将其与注释混合在一起,并且忽略了部分错误。从菜单栏中选择查看>导航器>显示日志导航器。在导航器中单击构建日志。查找失败的链接命令。右键单击失败的链接命令并选择“将显示结果(全部、所有消息)的转录本复制为文本”。编辑您的帖子并粘贴您复制的内容。不要试图将其放在评论中。@rob:已添加错误消息,请查看…@krish我刚刚忘记在答案中编写AVFoundation框架,dude。。但现在只需添加此项并检查它,还添加UIKIT框架??这些框架包括:Avuth.FrasWork/UIKIT.FrasWork/Buffy.FrasWorks/FCOReGraceC.FrasWork/OK这是框架的错误,我敢肯定,好了,现在添加CoreMedia框架试试吧,伙计,我刚刚添加了这些框架,是的,我当时也添加了,它成功了dude@krish也可以像#import#import#import一样导入这3个类
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)