网上很多说明block实现的教程,都是用下面的命令来讲objc的m文件转换为cpp文件
clang -rewrite-objc main.m
但是会报错
main.m:9:9: fatal error: 'Foundation/Foundation.h' file not found
#import <Foundation/Foundation.h>
^~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
正确的做法应该是
clang -x objective-c -rewrite-objc -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk main.m