Type 'SwinjectStoryboardOption' does not conform to protocol 'ServiceKeyOption'

987 Views Asked by At

After I did a clean install of my project Cocoapods which worked just before the clean install, now when I compile there is that error:

Type 'SwinjectStoryboardOption' does not conform to protocol 'ServiceKeyOption'

How do I fix it?

3

There are 3 best solutions below

0
Simon Moshenko On BEST ANSWER

TL;DR

Pretty clean fix is to go to Podfile.lock and look for Swinject, set it's version to 2.6.0 instead of 2.7.x. It will look like this:

  - Swinject (2.6.0)

As soon as SwinjectStoryboard releases a fix, you can just update the SwinjectStoryboard and it will automatically update Swinject to a proper version.

The issue

It looks like SwinjectStoryboard had a wrong dependency description in their podspec file:

s.dependency 'Swinject', '~> 2.6'

Which resulted in cocoapods picking any 2.x version which is higher than 2.6. So it mistakenly picks 2.7.x which is not compatible with current SwinjectStoryboard version.

Btw looks like the fix is on the way, it is on the master branch but not yet version tagged.

0
Mikolaj On

The error is caused by moving the Swinject to Swift 5 as part of their 2.7.0 release. At the moment of writing this, fix for it is already merged into master SwinjectStoryboard branch. What is missing is just releasing a new version.

So except of falling back to Swinject 2.6 there is also other temporary workaround (till official release would be made) - fetching the master branch content by defining in Podfile

pod 'SwinjectStoryboard' , :git => 'https://github.com/Swinject/SwinjectStoryboard.git', :branch => 'master'

There is a ticket dedicated to this.

0
tpbafk On

Another solution is adding

func hash(into: inout Hasher) {
    
}

to internal struct SwinjectStoryboardOption: ServiceKeyOption {<here>}.

The file's path should be Pods -> SwinjectStoryboard -> SwinjectStoryboardOption.swift