在Swift的CocoaTouchFramework中使用CocoaPods 0.36.0 [英] use CocoaPods 0.36.0 in CocoaTouchFramework with Swift
问题描述
我想在具有Swift类的CocoaTouchFramework中使用CocoaPods。
I would like to use CocoaPods in my CocoaTouchFramework, which has Swift classes.
我的Podfile看起来如下:
My Podfile looks the following:
platform :ios, '7.0'
inhibit_all_warnings!
link_with 'MyFramwork'
pod "AFNetworking", "2.5.0"
但是我如何实现包含 AFNetworking
进入我在CocoaTouch Framework中的 .swift
类中?没有桥接头,所以我不得不以某种方式直接将其导入到我的swift类中……
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是一个目标-c图书馆。因此,您需要一个桥接头并导入正确的头。
AFNetworking is an objective-c library. So you need to have a bridging-header and import the correct headers.
如果您想使用Swift库进行联网,则应该使用Alamofire。来自同一位创作者。将其放入您的Podfile中:
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'
在每个要使用它的Swift文件中,使用以下行导入库:
In every Swift file where you want to use it import the library with this line:
import Alamofire
这篇关于在Swift的CocoaTouchFramework中使用CocoaPods 0.36.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!