Clang 简单使用
clang -rewrite-objc: 将OC代码转成 C/C++
1. 最基本的
clang -rewrite-objc main.m
2.指定真机:
xcrun -sdk iphoneos clang -rewrite-objc main.m
指定模拟器:
xcrun -sdk iphonesimulator clang -rewrite-objc main.m
指定特定版本的SDK
xcrun -sdk iphonesimulator11.3 clang -rewrite-objc main.m
NOTE: 使用 xcodebuild -showsdks
可以查看系统的SDK。
clang ❯ xcodebuild -showsdks
iOS SDKs:
iOS 11.3 -sdk iphoneos11.3
iOS Simulator SDKs:
Simulator - iOS 11.3 -sdk iphonesimulator11.3
macOS SDKs:
macOS 10.13 -sdk macosx10.13
tvOS SDKs:
tvOS 11.3 -sdk appletvos11.3
tvOS Simulator SDKs:
Simulator - tvOS 11.3 -sdk appletvsimulator11.3
watchOS SDKs:
watchOS 4.3 -sdk watchos4.3
watchOS Simulator SDKs:
Simulator - watchOS 4.3 -sdk watchsimulator4.3
指定 framework
使用 -F
来指定引入的framework
xcrun -sdk iphonesimulator11.3 clang -rewrite-objc –F ${framework.path} main.m