我是一個新的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)
有人可以幫我解決這個問題嗎?謝謝!
你比我更清楚!尼斯。從我+1。 – Douglas