Cocoapods with Swift

Support Objective-C pods in a Swift project

Alexis Creuzot
Jun 4, 2014 · 2 min read

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.

Image for post
Image for post

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.

Image for post
Image for post

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.

Image for post
Image for post

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.

Image for post
Image for post

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 !

Image for post
Image for post

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.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store