最近有个Framework Demo在Xcode12.5.1编译正常,但用Xcode13.2.1编译却报错:Command MergeSwiftModule failed with a nonzero exit code
同时有相关报错提示信息如下(截取部分):
error: category 'extend' on interface 'AFHTTPSessionManager' has different definitions in different modules; first difference is definition in module 'XXXSDK.XXXAHttpConnect' found method name 'xxxMethod:'
but in 'XXX.XXXBHttpConnect' found method 'xxxOtherMethod:'
是由于本framework写了AFHTTPSessionManager
的分类,分类名为extend
,而本framework依赖的另一个SDK也对AFHTTPSessionManager
写了相同的分类名导致冲突:
@interface AFHTTPSessionManager(extend)
- (NSURLSessionDataTask *)xxxMethod;
@end
@implementation AFHTTPSessionManager(extend)
- (NSURLSessionDataTask *)xxxMethod {
// do somethings
}
@end
解决方式:
重命名分类名即可编译成功,可能存在第一次编译失败的情况,多编译两次即可。