2013-05-21 23 views
0

我是一個新的xcode,並試圖製作一個非常簡單的應用程序來播放按鈕被點擊時的噪音。我問了一個以前的問題,其中有一個錯誤,並且用戶建議我沒有正確導入AVFoundation.framework。我採納了他們的建議並設置了導入聲明,但現在出現錯誤。請參閱下面我的代碼:無法導入AVFoundation.framework,所以應用程序無法播放音樂?

我.h文件中:

#import <UIKit/UIKit.h> 
@interface FirstViewController : UIViewController 
@property (weak, nonatomic) IBOutlet UILabel *sampleText; 
@end 

我.m文件:

#import "FirstViewController.h" 
#import <AVFoundation/AVAudioPlayer.h> 
@interface FirstViewController() 
@end 

@implementation FirstViewController 
@synthesize sampleText = _sampleText; 

- (IBAction)beep:(UIButton *)sender { 
     NSURL* musicFile = [NSURL fileURLWithPath:[[NSBundle mainBundle] 
                pathForResource:@"button1" 
                ofType:@"mp3"]]; 
     AVAudioPlayer *click = [[AVAudioPlayer alloc] initWithContentsOfURL:musicFile error:nil]; 
     [click play]; 
    //[click release]; 
} 

然而,在建築,我得到一個鏈接錯誤:

Undefined symbols for architecture armv7s: 
    "_OBJC_CLASS_$_AVAudioPlayer", referenced from: 
     objc-class-ref in FirstViewController.o 
ld: symbol(s) not found for architecture armv7s 
clang: error: linker command failed with exit code 1 (use -v to see invocation) 

有人可以幫我解決這個問題嗎?謝謝!

回答

7

您還可以到AVFoundation框架添加到項目中。單擊左側源列表頂部的項目,選擇您的目標,轉到摘要窗格,然後單擊「鏈接的框架和庫」下的「+」按鈕。

+0

你比我更清楚!尼斯。從我+1。 – Douglas

2

確保你添加了框架。點擊左欄中的項目,向下滾動到框架並點擊添加。找到你需要的框架。

相關問題