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 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ファイルを含めて、私にいくつかの解決策を提案します

リンカエラーの可能性がありますが、ビルドフェーズからフレームワークを含め、#importフレームワークを含めました..何かが足りない場合は、以下のコードを確認してください...私は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

エラー :

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)
4

2 に答える 2

6

からフレームワークを追加Foundation.frameworkして試してみてください。AVFoundation.frameworkBuild Phases=>Link Binaries With Libraries

于 2013-01-02T05:21:58.087 に答える
0

AVFoundation.frameworkどういうわけか、プロジェクト内に名前が付けられた独自の壊れたフレームワークを作成しました。この壊れたフレームワークの存在は、リンカーがシステムのAVFoundationフレームワークを使用することを妨げています。

あなたはその中のすべてを削除する必要があり/Users/vaibhav/Iphone projects/Audioplaying/AVFoundation.frameworkます。

于 2013-01-02T06:35:21.540 に答える