您好,欢迎来到化拓教育网。
搜索
您的当前位置:首页使用clang将OC代码转为C++

使用clang将OC代码转为C++

来源:化拓教育网

使用clang命令,将.m文件转换成.cpp文件(cd到main.m的文件路径下:)

clang -rewrite-objc main.m

若有异常:
如:

异常一:fatal error: ****'UIKit/UIKit.h'filenotfound#import <UIKit/UIKit.h> ^**1error generated.

则:

  • 进入终端,键入命令vim ~/.bash_profile
  • 在vim界面输入i进入编辑编辑状态并且键入:
alias rewriteoc='clang -x objective-c -rewrite-objc -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk'
  • 键入完毕,点esc退出编辑状态,再键入:wq退出vim并保存,执行source ~/.bash_profile<-这句一定要执行,执行才会生效。
异常二 :'UIWebView' is unavailable: not available on macOS

则:

  • 指定真机
xcrun -sdk iphoneos clang -rewrite-objc main.m
  • 指定模拟器
xcrun -sdk iphonesimulator clang -rewrite-objc main.m
  • 指定SDK版本
xcrun -sdk iphonesimulator10.3 clang -rewrite-objc main.m
  • Ç语言转C ++
clang -rewrite-objc main.c

Copyright © 2019- huatuo9.cn 版权所有 赣ICP备2023008801号-1

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务