错误产生的原因:
include path for stdlibc++ headers not found; pass ‘-std=libc++’ on the command line to use
the libc++ standard library instead [-Wstdlibcxx-not-found]
xcode10 ios12已经彻底没有这个lib了
解决办法
直接去xcode9找到这-lstdc++.6.0.9 添加进去或者直接在网上找一个放进去,执行:
clang -x objective-c -rewrite-objc -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk main.m
期待着成功的出现,然而并没有,这次的警告和错误有下面这些:
clang: warning: using sysroot for 'iPhoneSimulator' but targeting 'MacOSX' [-Wincompatible-sysroot]
warning: include path for stdlibc++ headers not found; pass '-std=libc++' on the command line to use
the libc++ standard library instead [-Wstdlibcxx-not-found]
1 warning generated.
warning: include path for stdlibc++ headers not found; pass '-std=libc++' on the command line to use
the libc++ standard library instead [-Wstdlibcxx-not-found]
经过一番查找,参考 https://cotin.tech/iOS/clang-rewrite-objc/
这篇文章,使用如下命令:
xcrun -sdk iphonesimulator clang -rewrite-objc main.m
虽然还是有一些警告,但是实际上,对应的 main.cpp已经生产,可以进行分析了。
如果想知道当前的xcode支持哪些编译器sdk版本,可以使用以下命令:
xcodebuild -showsdks