iOS NSObjCRuntime错误解析

[Xcode]非Objc文件(c, c++)引起的NSObjCRuntime错误解析
1.以下是错误示例

#if DEBUG

#define NSLog(FORMAT, ...) fprintf(stderr,"[%s:%d行] %s\n",[[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String],   __LINE__, [[NSString stringWithFormat:FORMAT, ### #__VA_ARGS__] UTF8String]);

#else

#define NSLog(FORMAT, ...) nil

#import <Masonry.h>

#import "UIViewExt.h"

#endif

2.正确顺序


#import <Masonry.h>

#import "UIViewExt.h"

#if DEBUG

#define NSLog(FORMAT, ...) fprintf(stderr,"[%s:%d行] %s\n",[[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String], __LINE__, [[NSString stringWithFormat:FORMAT, ### #__VA_ARGS__] UTF8String]);

#else

#define NSLog(FORMAT, ...) nil

#endif

今天在objc工程中,导入一些c、c++文件时,,编译引起了NSObjCRuntime错误,,,仔细检查发现,
原来是在*.pch中,用上边错误的写法。调整顺序就可以正常编译了

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