0

Currently I'm working on an iOS application in swift. In my application I'm using FacebookShare pods(FBSDKCoreKit 4.46.0) for sharing contents to the Facebook. For that I was used FBSDKSharingDelegate. Today I updated the pod to FBSDKCoreKit to 5.6.0. After updating I got some suggestion in my code like

'FBSDKSharingDelegate' has been renamed to 'SharingDelegate'

So I changed it to SharingDelegate, also I changed in my code. But now its showing another error,

Redundant conformance of 'ProductDetailViewController' to protocol 'SharingDelegate'

I searched in google, and I didn't get any solution. Please help me.

These are the protocols I'm used in that ViewController class

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

}

I don't know which protocol is redundant with SharingDelegate.

These are the pod files that I'm using in the project, 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"

also I'm importing frameworks files in the class,

import ImageSlideshow
import AlamofireImage
import CoreLocation
import FacebookShare
import MessageUI
import SKActivityIndicatorView
import FBSDKShareKit
import FBSDKCoreKit
import MapKit
import GoogleMobileAds
import FBAudienceNetwork
Hilaj S L
  • 1,936
  • 2
  • 19
  • 31
  • error says you already conform to that protocol, don't search in google but in your code – Lu_ Sep 17 '19 at 06:15
  • I can't figure it out. Please help me. – Hilaj S L Sep 17 '19 at 08:08
  • did you do a clean rebuild? – Knight0fDragon Sep 23 '19 at 04:48
  • Yes I did. I quit the Xcode, install the pods one more time and then reopen the Xcode, still showing the same error. It was working before updating the FacebookShare pods. And when I updated the FacebookShare pods, FBSDKCoreKit pod file also updated to 5.6.0. And before updating, I'm using FBSDKSharingDelegate protocol, but after update I got suggestion to change it to SharingDelegate. After that I got this issue. – Hilaj S L Sep 23 '19 at 04:59
  • Now I commented the SharingDelegate protocol, now I can share the content to Facebook, But I don't get any callbacks in the delegate method. But I need the success callback to make an API call. – Hilaj S L Sep 23 '19 at 05:02
  • Are you by any chance having an extension of your customViewController in any other places? – Karthick Ramesh Sep 23 '19 at 23:18
  • No I checked, I used SharingDelegate protocol in this class only. Also there is no extension for this ViewController. – Hilaj S L Sep 24 '19 at 04:20

1 Answers1

2

According Facebook Documentation, SharingDelegate protocol in it's current version has only three functions:

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

}

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

}

func sharerDidCancel(_ sharer: Sharing) {

}

None of your other protocols override any of those functions, so your issue doesn't happen here.

You probably has an extension that also implements this protocol, I could reproduce the error like this:

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

}

extension UIViewController: SharingDelegate {

}

Output:

Redundant conformance of 'FBTestViewController' to protocol 'SharingDelegate'

Search your project for those SharingDelegate implementations (probably in extensions) and remove them.

EDIT

In your imports, comment this line:

//import FBSDKShareKit

The FacebookShare pod already imports it for you. That is the source of the problem.

alxlives
  • 5,084
  • 4
  • 28
  • 50
  • Hi alxlives I searched in my entire project but I didn't implement SharingDelegate anywhere my project other than this class. – Hilaj S L Sep 22 '19 at 05:36
  • Can you edit the question with your podfile and the imports you are using in this class? Also, please check if you happens to have a manual Facebook framework linked in the project that may be conflicting with the pod – alxlives Sep 22 '19 at 11:33
  • Hi I updated my question. Also I checked, I didn't add Facebook framework manually. I added only through pods – Hilaj S L Sep 23 '19 at 04:47
  • It was working before updating the FacebookShare pods. And when I updated the FacebookShare pods, FBSDKCoreKit pod file also updated to 5.6.0. And before updating, I'm using FBSDKSharingDelegate protocol, but after update I got suggestion to change it to SharingDelegate. After that I got this issue. – Hilaj S L Sep 23 '19 at 04:59