我是 xcode 的新手,并试图制作一个非常简单的应用程序,用于在单击按钮时播放噪音。我问了一个之前的问题,其中我有一个错误,用户建议我没有正确导入 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)
有人可以帮我解决这个问题吗?谢谢!