我已成功将“RestKit”pod添加到我的项目中,并按照本文中描述的步骤操作:
Cocoapods in swift.我将RestKit导入到我的ViewController类的源文件中:
import RestKit
但我不知道为什么我无法访问它.它不会显示RestKit中的任何类.表明:
‘RestKit’ No such module exists.
我再次尝试创建一个新项目并添加了“RestKit”.并创建了一个桥接头并将“RestKit”导入ViewController claas的源文件中.现在我运行该项目
它显示错误
// in this file Pods-SOCKit-prefix.pch #ifdef __OBJC__ #import <UIKit/UIKit.h> #endif #import "Pods-environment.h" // Pods-environment.h file not found // and also in this file Pods-TransitionKit-prefix.pch #ifdef __OBJC__ #import <UIKit/UIKit.h> #endif #import "Pods-environment.h" // Pods-environment.h file not found
如果有人知道这背后的问题是什么,请向我解释一下,并建议一种在Swift中使用RestKit的方法.
解决方法
我不确定你所拥有的Cocoapods问题.我将RestKit添加到我的桥接头,并且不需要将导入RestKit添加到我的Swift文件中.
我的桥接标题如下所示:
# if you are using Core Data: #import <CoreData/CoreData.h> #import <RestKit/RestKit.h> # if you are using Core Data: #import <RestKit/CoreData.h>