关于Xcode10中libstdc报错问题的解决

2,116 阅读1分钟

遇到问题

由于iPhoneXS以及iphoneXS_MAX在没有使用LaunchImage时,仍以iphoneX的为主,对适配不会产生什么影响。

iPhoneX_R在10月19号开始预订,26号出货,因此适配新机型迫在眉睫。由于没有拿到新机型,只能使用模拟器进行适配浏览。

使用Xcode10真机编译后,发现一直报错,报错内容如下:

报错显示没有找到libstdc++.6.0.9这个库,因此准备去Link Binary With Libraries中添加,进入后发现系统并没有提供该库.

碰到这个系统性的问题后,去官方论坛了搜索了一番,发现官方提供了解决的方案。官方的意思是libstdc++ 已经标记为废弃有5年了,建议大家使用全面支持C++11的 libc++ 库

解决方法

  1. 真机

    libstdc_iPhoneOS拷贝到/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib

  2. 模拟器

    libstdc_iPhoneSimulator拷贝到/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/lib/

    libstdc_iPhoneSimulator_runtime拷贝到/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/