How to import a Swift framework globally?

I want to have a way to import my Swift Cocoapods globally in every class, how can I achieve this?

I tried a lot of things and they didn't work. Here are some ways I haven't tried and thought may be possible if found a way to work them:

Have a general import statement like UIKit and put everything in there. (Edit: This failed)

Somehow put Swift frameworks in the Obj-C briding header and import the stuff in there.


Solution 1:

You should be able to import it globally by adding @_exported before the import.

@_exported import Podname

However, like the previous posters mentioned, this is not recommended.

Solution 2:

It's strongly discouraged in Swift because that would introduce implicit coupling between modules.

However, you can make a certain symbol available globally by declaring a typealias in the module that imports the other module:

import ModuleName
public typealias ClassName = ModuleName.ClassName