Cocoapods with Swift
Support Objective-C pods in a Swift project
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.
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.
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.
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 !
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 :
*Warning, some specific pods may not work or need additional configuration.