Cocoapods with Swift

Support Objective-C pods in a Swift project

Alexis Creuzot
2 min readJun 4, 2014

UPDATE : This article is now deprecated, you can import any pods very easily in Swift by just adding use_frameworks! in your Podfile !

First, create your Podfile and add the pods you need as usual.

Podfile

Install them using the pod install command and open the .xcworkspace file created in your project folder. Pods should now be included in your workspace.

Now for the interesting part. In order to use those pods, you are going to create a bridging header file. Click on File -> New -> File… and select “Header File” in the “Source” tab.

Name this file Bridging.h.

Open your project Build Settings and search for “Bridging”. Edit the key “Objective-C Bridging Header” to project_name/project_name-Bridging-Header.h.

Here my project is named “SwiftBasics”

You are now ready to add your imports into your Bridging-Header.h file for the pods you want to use, just as you would do in your .pch file.

Content of SwiftBasics-Bringing-Header.h

That’s it, you can now use your pods*. You don’t even have to import them again in your .swift files. You can also import any other Objective-C file added to your workspace this way. Sweet !

Using SVProgressHUD to show a message

I hope you liked this article, I’ll post more tips for Swift as I dive deeper into Swift. You can also find my some of my favorite Pods on this article :

7 Awesome Pods For Your iOS Projects

*Warning, some specific pods may not work or need additional configuration.

--

--