苹果在 XCode10 和 iOS12 中移除了 libstdc++ 这个库,由 libc++ 这个库取而代之,苹果的解释是 libstdc++ 已经标记为废弃有5年了,建议大家使用经过了 llvm 优化过并且全面支持C++11的 libc++ 库。
期初报错

后来拷贝libstdc++.6.0.9.tbd和libstdc++.6.0.9.dylib到模拟器的lib目录下报错提示消除,但是又出现了百度地图的报错提示:
Undefined symbols for architecture x86_64:
"std::ios_base::Init::~Init()", referenced from:
__GLOBAL__sub_I_BVMDOfflineMapMerge.cpp in BaiduMapAPI_Map(BVMDOfflineMapMerge.o)

原因:缺少副本文件:libstdc++.6.dylib、libstdc++.dylib、libstdc++.6.tbd、libstdc++.tbd。
解决方案:
方法一、下载libstdc++文件,拷贝到对应lib目录文件中。
lib对应目录:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libstdc++.6.0.9.dylib
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/libstdc++.6.0.9.tbd
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/libstdc++.6.0.9.tbd
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/lib/libstdc++.6.0.9.tbd
方法二、下载完毕后执行命令行导入文件,步骤:
1、到Github中下载该文件,并解压。
2、打开脚本文件确保里边的路径与自身XCode路径一致。
3、打开终端cd到libstdc--master文件夹,执行sudo sh install.sh,没有任何提示即脚本运行成功。
4、重启Xcode,在TARGETS->Build Phases->Link Binary With Libraries中添加libstdc++相关的库,运行程序,真机和模拟器都能启动。
网友评论