尝试使用 AVAudioPlayer 时出错

Error when trying to use AVAudioPlayer

以下代码产生以下错误。 不知道为什么?

NSString *soundFilePath = [NSString stringWithFormat:@"%@/abc.m4a",
                           [[NSBundle mainBundle] resourcePath]];
NSURL *soundFileURL = [NSURL fileURLWithPath:soundFilePath];

AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithContentsOfURL:soundFileURL
                                                               error:nil];
player.numberOfLoops = -1; //Infinite

[player play];

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

您需要为 AVFoundation 添加框架。