Classname conflict with multiple targets

I have the following scenario: an iOS app with multiple targets (widget, notification extensions, etc) and a 3rd party framework I include.

Now both the 3rd party framework and our code define a class named SomeClass. In a certain file, I'm using both and I cannot figure out how to refer to my own class instead of the 3rd party one:

import Some3rdPartFramework // imports "SomeClass"

class Bla {
    var item: SomeClass?  // swift seems to use Some3rdPartFramework.SomeClass, we want to use our own `SomeClass` here 
}

The only way I can refer to SomeClass in our own code is to prefix it with the module name, but that's different for every target...

How do I resolve this?

The only way I can refer to SomeClass in our own code is to prefix it with the module name, but that's different for every target...

How can the same class be defined in different modules?

Don't have the same source file be duplicated across multiple targets. Move this (and really all files where it's possible) into a single library target linked by all the others. Also cuts down on binary size as a neat side-effect.

Thatโ€™s unfortunately not a solution: frameworks negatively impact or app startup time by a lot.

I guess this is another one of this swift sharp edge thingies :frowning:

The impact of frameworks on startup time has decreased over the last few years, especially if they're Swift frameworks without Objective-C. Additionally, CocoaPods and SPM can statically link your dependencies, making the issue moot. You should really adopt the proper solution, a dependency manager, and deal with any launch speed issues if they appear.

2 Likes