Mach-O Linker Error When Adding Unit Tests - XCode

▼魔方 西西 提交于 2019-12-10 21:52:14

问题


I'm trying to add OCUnit tests to an existing project (in XCode 4.6.3). I followed the instructions here - http://twobitlabs.com/2011/06/adding-ocunit-to-an-existing-ios-project-with-xcode-4/ however I'm getting 78 Mach-O errors only when trying to run the tests. I can compile the main target just fine.

One thing to note I have not modified the tests yet, they are just the standard template. I'm not sure example what I'm doing wrong.

One error message

Undefined symbols for architecture i386: "_AudioComponentFindNext", referenced from: l651 in libNuanceSpeechAnywhere.a(libSpeechKit.a-i386-master.o) l652 in libNuanceSpeechAnywhere.a(libSpeechKit.a-i386-master.o)

Here is a screen shot of a bunch of the errors.


回答1:


You have to add AudioUnit framework to your project first and then rebuild it.

This is how you add frameworks to your project.




回答2:


After banging my head against the keyboard for a few hours, I found this solution if you're using CocoaPods:

In your podfile, add your test target as well with the necessary dependencies

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

Then just run pod install and everything should end up configured correctly. I recommend running pod install --verbose so you can see if there are any warnings. If you manually edited the build configuration, Pod will complain about it. Follow the recommendation and then reinstall. Works like a charm.



来源:https://stackoverflow.com/questions/21147779/mach-o-linker-error-when-adding-unit-tests-xcode

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!