I have an enum in one of my Swift files called Foo
.
One of the Cocoapods called NameA
also has the same enum with name Foo
(public enum
, not inside any class).
This module also has a class with the same name as its framework NameA
.
If I try to refer to Foo
in NameA
module like this:
NameA.Foo
It doesn't work because the compiler thinks I'm referring to the class NameA
, but not the module NameA
.
The workaround posted here wont work for me either Swift namespace conflict
This seems to be a reported bug in swift: https://bugs.swift.org/browse/SR-898
Don't import NameA
.
Instead, import enum NameA.Foo
(notice the keyword "enum", can also be used for "struct" or "class" or "func")
Reference either Foo
(your enum) or NameA.Foo
(their enum).
If you need to reference NameA
in the same file as NameA.Foo
:
import NameA
typealias NameAWrapper = NameA
NameA
as NameAWrapper
in your other files without importing the module directly.This was inspired by this workaround (which you linked to), but modified slightly based on your situation: https://stackoverflow.com/a/26774102/358806
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With