美文网首页
记录解决Xocde10 编译缺少stdc++.6.0.9问题

记录解决Xocde10 编译缺少stdc++.6.0.9问题

作者: Helson | 来源:发表于2019-08-14 10:25 被阅读0次

错误提示:library not found for -libstdc++.6.0.9

报错原因

Xcode10开始苹果粑粑把libstdc++替换为libc++,libc++相对是苹果最新版的C++库,经过优化并全面支持C++11。我们的项目里使用到的一个另外部门开发的SDK。每次pod install都会报错。跨部门沟通无果(人家说没有用libc++了😑),还是自己解决吧。

解决办法(推荐使用第2种方法)

  1. 下载libstdc++文件,并拷贝到Xcode目录下。目录如下:
  • 真机环境:
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/
  • 模拟器环境:
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/lib/
  1. 在Podfile中增加post_install的hook,将stdc++.6.0.9替换成c++。
post_install do |installer_representation|
  installer_representation.pods_project.targets.each do |target|
    #TargetName为自己项目的Target名
    if target.name == 'Pods-TargetName'
      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

相关文章

网友评论

      本文标题:记录解决Xocde10 编译缺少stdc++.6.0.9问题

      本文链接:https://www.haomeiwen.com/subject/aigwjctx.html