Use Cocoa Pods with Swift

von tobonaut

Apple released Swift a couple of days ago. My new language of choice. No more boilerplate Objective-C code with ugly attached blocks. But can I use the same nice things as I was used to under Objective-C? With ’nice things‘ I mean CocoaPods. The hero which prevents me from the library hell.

The answer is yes and it is quite simple.

Step-by-step list

  1. Create and build your Podfile
  2. Open Xcode (Beta 6)
  3. Create a header file which works as ‚bridge‘ between the objc Pods and your Swift application. You may call it bridge.h (see appendix #1)
  4. Import your Pods
  5. Open your project settings and append the file to build setting / Objective-C Bridging Header (see appendix #2)
  6. That’s it. Now, you can use your Pods the same way as before just with the new Swift syntax.

Appendix #1


Appendix #2