0

I would like to use CocoaPods in my CocoaTouchFramework, which has Swift classes.

My Podfile looks the following:

platform :ios, '7.0'
inhibit_all_warnings!

link_with 'MyFramwork'

pod "AFNetworking", "2.5.0"

But how do I achieve to include e.g. AFNetworking into my .swift class in the CocoaTouch Framework? There's no briding header so I somehow have to import it directly in my swift class...

MGY
  • 7,245
  • 5
  • 41
  • 74
swalkner
  • 16,679
  • 31
  • 123
  • 210
  • Are you still having issues? Have you tried using a bridging header? Need more direction? – Firo Mar 27 '15 at 12:16

3 Answers3

1

AFNetworking is an objective-c library. So you need to have a bridging-header and import the correct headers.

If you want to use a Swift library for networking you should look to Alamofire. It's from the same creator. Put this in your podfile:

pod 'Alamofire', '~> 1.1'

In every Swift file where you want to use it import the library with this line:

import Alamofire
JorgeDeCorte
  • 779
  • 1
  • 8
  • 9
0

You need to import AFNetworking, just using in your Swift files:

import AFNetworking

Be careful with upper/lower case letters, as autocompletion does not work. Import every pod library you need to use, using its name (i.e., the name of the folder inside the Pods group/directory)

Diego Freniche
  • 5,225
  • 3
  • 32
  • 45
0

If you want to use AFNetworking pod, try to add an Objective-C class by using File->New->File->Cocoa Touch Class. Xcode will ask you to add bridge header. In your bridge header you can import AFNetworking such as;

#import <AFNetworking/AFNetworking.h>

If you don't want to use bridge header you should use Alamofire pod.

ridvankucuk
  • 2,407
  • 1
  • 23
  • 41