2

I'm trying to implement git project XLPagerTabStrip.

According to the project, every controller has to:

Every view controller provided by PagerTabStripDataSource's viewControllers(for:) method must conform to InfoProvider

But the following code throws: does not conform to protocol

extension UserProfileSubController: IndicatorInfoProvider {

    func indicatorInfo(for pagerTabStripController: PagerTabStripViewController) -> IndicatorInfo {

        return IndicatorInfo(title: "UserProfileSubController")
    }
}

enter image description here

enter image description here

enter image description here

If I want to auto fix the issue it re-implements the same protocol function and then throws invalid redeclaration.

enter image description here

How do you fix does not conform to protocol issue if your controller in fact does conform to it? What am I missing? Help is very appreciated.

PS: I have cleaned the project, the build folder, removed derived data, restarted and performed pod updated as well as reinstall of pod.

David Seek
  • 16,783
  • 19
  • 105
  • 136
  • I tried your code in a sample project and it worked. I didnt use the pod but downloaded the source code directly from github – Puneet Sharma Nov 08 '17 at 16:19
  • i guess there is some redeclaration or protocol extensions error that i'm currently missing. was hoping there is some kind of easier solution to find the actual error. thank you for your effort – David Seek Nov 08 '17 at 16:23

3 Answers3

0

Check the IndicatorInfo class is like the following way:

public struct IndicatorInfo {

    public var title: String?
    public var image: UIImage?
    public var highlightedImage: UIImage?

    public init(title: String?) {
        self.title = title
    }

    public init(image: UIImage?, highlightedImage: UIImage? = nil) {
        self.image = image
        self.highlightedImage = highlightedImage
    }

    public init(title: String?, image: UIImage?, highlightedImage: UIImage? = nil) {
        self.title = title
        self.image = image
        self.highlightedImage = highlightedImage
    }

}

instead of public struct IndicatorInfo{} you used public protocol IndicatorInfo{}

And i hope you can only use one protocol in a single class.

extension YourViewController : IndicatorInfoProvider {

    // MARK: - Top Tab Bar Method - IndicatorInfoProvider
    func indicatorInfo(for pagerTabStripController: PagerTabStripViewController) -> IndicatorInfo {
        return IndicatorInfo(title: "titleStringHere", image: UIImage(named: "Your_Image_Name"))
       /*or   return IndicatorInfo(title: "titleStringHere") */
    }
}
Ram Madhavan
  • 2,362
  • 1
  • 17
  • 20
0

In the end it was copy/pasting/dependency issue. Starting over and removing the pod and dependency code and re-installing solved the issue at the end.

David Seek
  • 16,783
  • 19
  • 105
  • 136
-1

I'm not sure if this is going to work, but try these:

  1. put the code in the class not in the extension.
  2. use this specific pod pod 'XLPagerTabStrip', '~> 7.0'
Joseph Francis
  • 1,111
  • 1
  • 15
  • 26