将.m 编译为 .cpp

xcrun -sdk iphoneos clang -arch arm64 -rewrite-objc xxx.m -o xxx.cpp

-sdk 指定编译的平台
-arch 指定编译架构

遇到错误

 xcrun -sdk iphoneos clang -arch arm64 -rewrite-objc main.m -o main.cpp
xcrun: error: SDK "iphoneos" cannot be located
main.m:8:9: fatal error: 'Foundation/Foundation.h' file not found

解决方法:

sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer/

你可能感兴趣的:(将.m 编译为 .cpp)