libstdc++在Xcode10中已经移除,苹果现在用libc++代替libstdc++,那么项目中如果使用了libstdc++改这么办?
如果是自己工程使用了libstdc++,就用libc++代替。但是如果是第三方使用了,只能等待第三方更新。
但是我们还有一种临时解决办法。
解决办法
1.从Xcode9中拷贝模拟器和真机libstdc++库
如果嫌麻烦,可以从这个Git下载
模拟器路径
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/lib
真机路径
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib
拷贝下面三个库
然后复制到Xcode10下相同路径下。
这时候运行会报错
Reason: no suitable image found. Did find:
/usr/lib/libstdc++.6.dylib: mach-o, but not built for iOS simulator
2.编译运行库拷贝
在Xcode9下,从路径 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib 复制这三个库到对应的Xcode10相同路径下。
至此,无论真机还是模拟器编译都正常了。