1.[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错误,,,仔细检查发现,
原来是在SK_Prefix.pch中,用上边错误的写法,花了好久才找到原因,分享给你们!

本文详细解析了在使用Xcode进行Objective-C开发时,导入C、C++文件导致的NSObjCRuntime错误。通过案例分析,作者分享了解决错误的正确导入顺序,并提供了避免此类问题的建议。
2359

被折叠的 条评论
为什么被折叠?



