在 iOS Swift 中将 FBSDKCore 更新到 5.6.0 后,'ViewController' 与协议 'SharingDelegate' 的冗余一致性

Redundant conformance of 'ViewController' to protocol 'SharingDelegate' after updating the FBSDKCore to 5.6.0 in iOS Swift

目前我正在 swift 开发 iOS 应用程序。在我的应用程序中,我使用 FacebookShare pods(FBSDKCoreKit 4.46.0) 将内容共享到 Facebook。为此,我使用了 FBSDKSharingDelegate。今天把pod更新到FBSDKCoreKit到5.6.0。更新后我在我的代码中得到了一些建议,比如

'FBSDKSharingDelegate' has been renamed to 'SharingDelegate'

所以我把它改成了SharingDelegate,我也改变了我的代码。但现在显示另一个错误,

Redundant conformance of 'ProductDetailViewController' to protocol 'SharingDelegate'

我在google中搜索,但没有得到任何解决方案。请帮助我。

这些是我在其中使用的协议 ViewController class

class customViewController: UIViewController, UITableViewDelegate, UITableViewDataSource, UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout, MFMailComposeViewControllerDelegate, UIGestureRecognizerDelegate, UITextViewDelegate, UIScrollViewDelegate, GADBannerViewDelegate, SharingDelegate 
{

}

不知道哪个协议和SharingDelegate是多余的

这些是我在项目中使用的 pod 文件, pod 'Alamofire', '~> 4.5'

pod 'AlamofireImage', '~> 3.0'
pod 'SwiftyJSON'
pod 'RAMAnimatedTabBarController'

pod 'FacebookCore', '0.9.0'
pod 'FacebookLogin', '0.9.0'
pod 'FacebookShare', '0.9.0'
pod 'FBAudienceNetwork'

pod 'GoogleMaps', '~> 3.3.0'
pod 'GooglePlaces', '~> 3.3.0' 
pod 'GoogleSignIn' 
pod 'Google-Mobile-Ads-SDK' 

pod 'SideMenu'
pod "QRCode"
pod 'SwipeMenuViewController', '~> 2.0.0'
pod "ScrollingFollowView"
pod 'DLRadioButton', '~> 1.4'
pod 'AZDialogView'

pod 'Firebase/Core'
pod 'Firebase/Auth'
pod 'Firebase/Messaging'

pod 'SKActivityIndicatorView', '~> 0.1.0'
pod 'SwiftyGif'
pod 'ImageSlideshow', '~> 1.6'
pod "ImageSlideshow/Alamofire"
pod 'SDWebImage', '~> 4.0'
pod "PhotoSlider"
pod 'lottie-ios'
pod 'CardsLayout'
pod 'Fabric', '~> 1.10.2'
pod 'Crashlytics', '~> 3.13.2'
pod "SkeletonView"

我也在 class、

中导入框架文件
import ImageSlideshow
import AlamofireImage
import CoreLocation
import FacebookShare
import MessageUI
import SKActivityIndicatorView
import FBSDKShareKit
import FBSDKCoreKit
import MapKit
import GoogleMobileAds
import FBAudienceNetwork

根据Facebook DocumentationSharingDelegate当前版本的协议只有三个功能:

func sharer(_ sharer: Sharing, didCompleteWithResults results: [String : Any]) {

}

func sharer(_ sharer: Sharing, didFailWithError error: Error) {

}

func sharerDidCancel(_ sharer: Sharing) {

}

None 您的其他协议会覆盖任何这些功能,因此您的问题不会发生在这里。

你可能有一个扩展也实现了这个协议,我可以像这样重现错误:

class FBTestViewController: UIViewController, UITableViewDelegate, UITableViewDataSource, UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout, MFMailComposeViewControllerDelegate, UIGestureRecognizerDelegate, UITextViewDelegate, UIScrollViewDelegate, GADBannerViewDelegate, SharingDelegate {

}

extension UIViewController: SharingDelegate {

}

输出:

Redundant conformance of 'FBTestViewController' to protocol 'SharingDelegate'

在您的项目中搜索那些 SharingDelegate 实现(可能在扩展中)并删除它们。

编辑

在您的导入中,注释此行:

//import FBSDKShareKit

FacebookShare pod 已经为您导入了它。这就是问题的根源。