在ios中使用AVAudioSession时出错

在ios中使用AVAudioSession时出错,ios,objective-c,xcode,Ios,Objective C,Xcode,我用了这些密码 - (void)viewDidLoad { [[AVAudioSession sharedInstance] setDelegate: self]; [[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryAmbient error: nil]; AudioSessionAddPropertyListener ( kAudioSessi

我用了这些密码

- (void)viewDidLoad
{
[[AVAudioSession sharedInstance] setDelegate: self];
[[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryAmbient error: nil];
AudioSessionAddPropertyListener (
                                 kAudioSessionProperty_AudioRouteChange,
                                 audioRouteChangeListenerCallback,
                                 self
                                 );
NSError *activationError = nil;
[[AVAudioSession sharedInstance] setActive: YES error: &activationError];
}

检测音频插孔在我的项目中是否插入或拔出,但最终出现此错误

Undefined symbols for architecture armv7:
  "_AVAudioSessionCategoryAmbient", referenced from:
      -[ViewController viewDidLoad] in ViewController.o
  "_OBJC_CLASS_$_AVAudioSession", referenced from:
      objc-class-ref in ViewController.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

那么其中的问题是什么呢?我是ios初学者,如有任何帮助,将不胜感激。

您将错过将
AudioToolBox.Frameworks
添加到项目文件的机会。仔细检查项目文件设置

更新 实际上错过了在项目的构建阶段添加的AVFoundation.Frameworks

更新2

已删除尾随的
s
。现在是
AudioToolBox.Framework
AVFoundation.Framework

你导入了这个
import
吗?你添加了
AVFoundation.Frameworks
?是的,我导入了是的AVFoundation.Frameworks没有在构建阶段添加,现在我手动添加了,谢谢
Undefined symbols for architecture armv7:
  "_AVAudioSessionCategoryAmbient", referenced from:
      -[ViewController viewDidLoad] in ViewController.o
  "_OBJC_CLASS_$_AVAudioSession", referenced from:
      objc-class-ref in ViewController.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)