通过clang看OC底层C++文件
2019-05-15 本文已影响0人
仙鱼大叔
想了解oc底层的c++文件是怎样的,然后执行clang -rewrite-objc ViewController.m时报错
In file included from ViewController.m:9:
./ViewController.h:9:9: fatal error: 'UIKit/UIKit.h' file not found
#import <UIKit/UIKit.h>
^~~~~~~~~~~~~~~
1 error generated.
解决办法:
clang -x objective-c -rewrite-objc -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk xxxxx.m
可通过alias简化如下:
1、进入终端输入
vim ~/.bash_profile
2、在vim界面输入i进入编辑状态然后输入:
alias writeoctoc='clang -x objective-c -rewrite-objc -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk'