问题
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