./ViewController.h:9:9: fatal error: 'UIKit/UIKit.h' file not found

clang编译的两种方法

1.使用绝对路径:

clang -rewrite-objc -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk xx/xx/y.m(文件的绝对路径) 

通过上述命令即可编译通过

2.修改全局变量

vim ~/.bash_profile

在终端输入i键入

alias rewriteoc='clang -x objective-c -rewrite-objc -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk'


点击esc返回输入:wq退出
 
终端再次输入 source ~/.bash_profile 环境变量生效
 
再次编译成C++代码
只需要输入 rewriteoc + 文件的绝对路径

 

posted @ 2019-12-04 19:04  tryFighting  阅读(824)  评论(0编辑  收藏  举报