János
János

Reputation: 35114

Import framework for whole project at one place in Swift?

I made an own Cocoa Touch Framework, and I want to import it only at one place in the code. In Xcode / earlier in Objective C there were a central location under Supporting Files. How does it work for Swift based project?

Upvotes: 8

Views: 5625

Answers (2)

acecilia
acecilia

Reputation: 938

As I answered here: https://stackoverflow.com/a/46878808/3203441

As of Swift4:

  • Being in a Swift project
  • Want to have another Swift project globally imported (and using cocoapods)

I just managed to do that by adding the following line to my bridging header:

#import <PodName/PodName-Swift.h>

How good/bad this practise is? Not sure, but I just wanted some extensions globally available in my project. this did the trick.

Upvotes: 0

Valentin
Valentin

Reputation: 3302

Create a Frameworks folder. Drag and drop your framework in it. Then create a bridging header file (easiest way to do this in Swift project is by adding an objective c class and it will ask you to create that bridging file for you). Then in your bridging header file just add

#import <YourFramework/YourFramework.h>

Then your framework classes are accessible from Swift. Hope this helps!

Upvotes: 2

Related Questions