Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to import a Swift framework globally?

Tags:

ios

swift

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.

like image 752
Esqarrouth Avatar asked Nov 01 '15 08:11

Esqarrouth


People also ask

How do I import a framework?

To embed your frameworks, you shouldn't use the build settings directly, but go to the General tab of the project editor for your app target (select the project item in the navigator, then select the target in the editor pane, then select the General tab). Add your framework under "Embedded Binaries".

Do I need to import UIKit?

You should import it into every file that uses UIKit. That should be your View and Controller classes. Model classes should almost never use UIKit.


1 Answers

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.

like image 133
Christoffer Winterkvist Avatar answered Sep 19 '22 18:09

Christoffer Winterkvist