XCode 12:“SessionDelegate"在不同模块中有不同的定义 [英] XCode 12: 'SessionDelegate' has different definitions in different modules

查看:16
本文介绍了XCode 12:“SessionDelegate"在不同模块中有不同的定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此问题发生在 XCode 12 Beta5 之后.Xcode 不允许不同的模块定义相同的名称(可能用于公共类和协议).Alamofire 和 Kingfisher 似乎同时定义了 SessionDelegate.我仍在努力寻找解决方案..

This problem occurs after XCode 12 Beta5. Xcode doesn't allow different modules to define same names (Probably for public classes & protocols). Alamofire and Kingfisher appears to define SessionDelegate at the same time. I'm still trying to find a solution..

我正在我们的应用程序中实现 iOS 14 小部件.我已经开始使用 XCode 12 Beta 2 并且一切都编译得很好.当我将 XCode 更新到 XCode 12 Beta 6 时,我遇到了以下错误:

I'm implementing iOS 14 Widgets in our application. I have started working with XCode 12 Beta 2 and everthing was compiling fine. When I have updated XCode to XCode 12 Beta 6, I faced with following error:

'SessionDelegate'在不同的模块中有不同的定义;第一个区别是模块Kingfisher.Swift"中的定义找到了结尾班级

'SessionDelegate' has different definitions in different modules; first difference is definition in module 'Kingfisher.Swift' found end of class

我还附上了错误文件的屏幕截图.

I'm also attaching the screenshot of the file with error.

有什么方法可以编辑头文件,为 Alamofire 或 Kingfisher 的 SessionDelegate 使用不同的名称?是否有解决此问题的解决方法?

Is there any way to edit header files to have different names for SessionDelegate for Alamofire or Kingfisher? Is there any workaround to overcome this issue?

以下是我迄今为止尝试过的方法:

Here are things I have tried so far:

  • 我已将 Alamofire 和 Kingfisher 都更新到最新版本
  • 我已经清理了 Podfile.lock 和所有 Pod 以及派生数据
  • 我尝试使用旧版构建系统
  • 进行编译
  • I have updated both Alamofire and Kingfisher to latest version
  • I have cleaned Podfile.lock and all pods as well as Derived Data
  • I tried to compile with Legacy Build System

推荐答案

此时(Xcode 12.0 或 Xcode 12.2b2),唯一可能的解决方案是重命名 Objective-C 接口并避免冲突.这可以通过以下方式之一完成:

At this moment (Xcode 12.0 or Xcode 12.2b2), the only possible solution is to rename the Objective-C interface and avoid conflicts. This could be done by one of:

  • 完全重命名冲突类,更新所有使用它的地方(例如,将 SessionDelegate 替换为 KingfisherSessionDelegate)
  • @objc(...) 属性添加到 Swift 类,这将更新生成的 ...-Swift.h 文件中的 Obj-C 接口并避免名称冲突.
  • Rename conflicting class entirely, update all places where it's used (e.g. replace SessionDelegate by KingfisherSessionDelegate)
  • Add @objc(...) attribute to a Swift class, which will update the Obj-C interface in a generated ...-Swift.h file and avoid the names conflict.
//  SessionDelegate.swift
@objc(KFSessionDelegate)
class SessionDelegate: NSObject { ... }

//  Kingfisher-Swift.h
@interface KFSessionDelegate : NSObject
...
@end

此解决方案已包含在 Kingfisher 5.15.4 版本中并且可以应用于任何其他库和您自己的框架.

This solution is already included in the Kingfisher 5.15.4 release and could be applied to any other libraries and your own frameworks.

此外,Apple 论坛上的主题:https://developer.apple.com/forums/线程/658012

Also, the thread on Apple forums: https://developer.apple.com/forums/thread/658012

这篇关于XCode 12:“SessionDelegate"在不同模块中有不同的定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆