Objective-C编译成C++代码报错(ViewController)

错误一:In file includedfromViewController.m:9:**./ViewController.h:9:9: ****fatal error: ****'UIKit/UIKit.h'filenotfound**#import <UIKit/UIKit.h>** ^**1error generated.

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<-这句一定要执行,执行才会生效

错误二: 'UIWebView' is unavailable: not available on macOS

解决办法:

指定真机

xcrun -sdk iphoneos clang -rewrite-objc ViewController.m

指定模拟器

xcrun -sdk iphonesimulator clang -rewrite-objc ViewController.m

指定SDK版本

xcrun -sdk iphonesimulator10.3 clang -rewrite-objc ViewController.m

Ç语言转C ++

    zhangquaniMac:~ zq$ cd /Users/zq/Desktop/Test/Test

    zhangquaniMac:Test zq$ clang -rewrite-objc main.c

参考:

HTTPS://cotin.tech/iOS/clang-rewrite-objc/

https://blog.csdn.net/qq_34003239/article/details/84230019

https://www.jianshu.com/p/43a09727eb2c

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容