添加unit testing时的Mach-O链接器错误 – XCode

我正在尝试将OCUnittesting添加到现有项目(在XCode 4.6.3中)。 我按照这里的说明 – http://twobitlabs.com/2011/06/adding-ocunit-to-an-existing-ios-project-with-xcode-4/然而,我只得到78个马赫 – O错误试图运行testing。 我可以编译主要目标就好了。

有一件事要注意,我还没有修改testing,他们只是标准的模板。 我不知道我做错了什么。

一个错误消息

架构i386的未定义符号:“_AudioComponentFindNext”,引用自libNuanceSpeechAnywhere.a(libSpeechKit.a-i386-master.o)中的l651:libNuanceSpeechAnywhere.a中的l652(libSpeechKit.a-i386-master.o)

这里是一堆错误的屏幕截图。

在这里输入图像说明

您必须先将AudioUnit框架添加到您的项目中,然后重新构build它。

这是你如何添加框架到你的项目。

在将我的头撞在键盘上几个小时之后,如果您使用CocoaPods,我发现了这个解决scheme:

在您的podfile中,添加您的testing目标以及必要的依赖关系

 workspace 'MyProject' target 'MyProject' do use_frameworks! pod 'Alamofire', '~> 4.0' pod 'RealmSwift' end target 'MyProjectTests' do use_frameworks! pod 'Alamofire', '~> 4.0' pod 'RealmSwift' end post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| config.build_settings['SWIFT_VERSION'] = '3.0' end end end 

然后运行pod安装,一切都应该正确configuration。 我build议运行pod install –verbose,以便看到是否有任何警告。 如果您手动编辑构buildconfiguration,Pod会抱怨。 按照build议,然后重新安装。 奇迹般有效。