Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'Decodable' naming conflict in Swift 4 #148

Open
chrismanderson opened this issue Jun 6, 2017 · 9 comments
Open

'Decodable' naming conflict in Swift 4 #148

chrismanderson opened this issue Jun 6, 2017 · 9 comments

Comments

@chrismanderson
Copy link

Swift 4 includes a built in Decodable protocol. Tried to build my project in Swift 4/Xcode 9 and got naming conflicts all over the place.

Obviously, it's early, but wanted to bring this to everyone's attention! I'm not sure what development of this library will look like in the future but figured this issue could begin that conversation.

Thanks!

@GeorgeSealy
Copy link

I've seen the same - the compiler is unable to distinguish Decodable as either Swift.Decodable or Decodable.Decodable.

Specifying Decodable.Decodable doesn't help in this case - this may be a compiler issue as I feel this should work (happy to be corrected on this!)

@voidref
Copy link
Collaborator

voidref commented Jun 7, 2017

Looks like this lib is going to have to do the Enum namespace hack, and come up with something besides Decodable for the namespace.

@nap-sam-dean
Copy link
Contributor

nap-sam-dean commented Jun 7, 2017

You can work around this issue (for now) by importing just the protocol before importing the whole module:

import protocol Decodable.Decodable
import Decodable

This allows this struct to compile:

struct MyStruct: Decodable { ... }

Obvious caveats here, this might just be an implementation detail of Swift 4 and might stop working on the next Xcode 9 beta release.

@chrismanderson
Copy link
Author

Doing import protocol Decodable.Decodable worked for me. Assuming it is not a permanent fix, but great to be be able to build my app in Xcode 9.

@Lascorbe
Copy link

Lascorbe commented Jun 7, 2017

What about DecodingError? Any (fast) workaround for that? :)

@nap-sam-dean
Copy link
Contributor

import protocol Decodable.Decodable
import enum Decodable.DecodingError
import Decodable

@Lascorbe
Copy link

Lascorbe commented Jun 8, 2017

Weird, tried that and got an error, it works fine now tho. Thanks @nap-sam-dean! 🍻

@polqf
Copy link

polqf commented Jul 8, 2017

FYI I opened a ticket in JIRA when I first got this error 😄
https://bugs.swift.org/browse/SR-5110

@Ankish
Copy link

Ankish commented Dec 7, 2017

It build and runs with this solution. If I try to Profile my app - profiling stops at
import protocol Decodable.Decodable - No Such module Decodable. Anyone checked this ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants