低版本Xcode升级到Xcode10之后,将废弃libstdc++6.0.9的库,导致很多用到这个库的项目会报出library not found for -lstdc++.6.0.9错误。
手动依赖了第三方库导致报错,如何解决(临时方案)
升级第三方库,或将低版本Xcode9的libstdc++6.0.9.tbd拷贝到Xcode10的目录下 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform(模拟器下运行:iPhoneSimulator.platform)/Developer/SDKs/iPhoneOS.sdk/usr/lib/
注意: 此方法只能暂时性解决问题,Xcode升级后需要重新拷贝libstdc++6.0.9.tbd
CocoaPods依赖第三方库报错解决方案(推荐使用)
在Podfile中增加post_install的hook,移除Pods目录重新pod install即可,hook部分代码如下
platform :ios, '9.0'
use_frameworks!
target "DEMO" do
pod 'MJRefresh'
end
post_install do |installer_representation|
installer_representation.pods_project.targets.each do |target|
// DEMO 为自己项目的target名
if target.name == 'Pods-DEMO'
target.build_configurations.each do |config|
xcconfig_path = config.base_configuration_reference.real_path
xcconfig = File.read(xcconfig_path)
new_xcconfig = xcconfig.sub('stdc++.6.0.9', 'c++')
File.open(xcconfig_path, "w") { |file| file << new_xcconfig }
end
end
end
end