I am trying to reference a type inside a framework that has a type whose name is the same as the framework. Easier to explain in code:
In Framework Something
public struct A { ... }
public class Something { ... }
In Framework OtherFramework
public struct A { ... }
Then on the main project I import both modules:
import Something
import OtherFramework
let myA = A() // 'A' is ambiguous for type lookup in this context
And if I do
import Something
import OtherFramework
let myA = Something.A() // 'A' is not a member type of 'Something'
Is there any way to reference A
in Something
other than changing the framework?
One possible way is not to import the whole module, import only the specific types you need, e.g. to import a class Something
in module Something
:
import class Something.Something
One solution I found is to create a separate .swift file with this:
import Something
typealias SomethingA = A
And then
import Something
import OtherFramework
let myA = SomethingA()
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