1、想了解OC通过runtime机制转成的C++代码是什么样子的,在进入项目目录中
/Applications/Xcode.app/ 是xcode的绝对路径(查看包内容找到层级,根据自己电脑)
clang -x objective-c -rewrite-objc -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk xxxxx.m
2、不能每次都输入这么长的路径和命令,可通过alias简化工作,步骤:
1、进入终端,键入命令 vim ~/.bash_profile
2、在vim界面输入i进入编辑编辑状态并且键入:alias rewriteoc='clang -x objective-c -rewrite-objc -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk'
3、 键入完毕,点esc退出编辑状态,再键入:wq退出vim并保存,执行source ~/.bash_profile <-这句一定要执行,执行才会生效
4、 进入到工程目录 找到需要重新查看的文件 执行下面命令
rewriteoc main.m
5、此时目录里应该多了一个同名.cpp文件。
网友评论