Use Cocoa Pods with Swift

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

swift-pods-1

Appendix #2

swift-pods-2

Schreibe einen Kommentar

Trage deine Daten unten ein oder klicke ein Icon um dich einzuloggen:

WordPress.com-Logo

Du kommentierst mit Deinem WordPress.com-Konto. Abmelden / Ändern )

Twitter-Bild

Du kommentierst mit Deinem Twitter-Konto. Abmelden / Ändern )

Facebook-Foto

Du kommentierst mit Deinem Facebook-Konto. Abmelden / Ändern )

Google+ Foto

Du kommentierst mit Deinem Google+-Konto. Abmelden / Ändern )

Verbinde mit %s