OC转c++

2018-08-13  本文已影响0人  开心一刻_
clang  -rewrite-objc  main.m

报错

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

解决方法:

clang -x objective-c -rewrite-objc -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.0.sdk ViewController.m

永久解决办法

$vim ~/.bash_profile 
$alias rewriteoc=‘clang -x objective-c -rewrite-objc -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.0.sdk’
$source ~/.bash_profile

增加weak还可以转换c++的解决办法

clang -rewrite-objc -fobjc-arc -stdlib=libc++  -fobjc-runtime=macosx-11.0 -Wno-deprecated-declarations -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.0.sdk ViewController.m
上一篇 下一篇

猜你喜欢

热点阅读