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...
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
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)
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.