Objective c 类似乎是在更新Cocoapods gem后从测试中的不同NSBundle加载的,结果是零单例

Objective c 类似乎是在更新Cocoapods gem后从测试中的不同NSBundle加载的,结果是零单例,objective-c,cocoapods,nsbundle,Objective C,Cocoapods,Nsbundle,我正在应用程序中使用RestKit,并在AppDelegate中进行设置。我有一些依赖于RKObjectManagersingleton的单元测试。这是在AppDelegate中设置的。一些测试专门为测试设置托管对象存储,如下所示。其他人直接对其调用getObjectetc来测试响应映射 这在我的测试设置中: RKObjectManager *mgr = [RKObjectManager sharedManager]; [mgr setManagedObjectStore:managedObje

我正在应用程序中使用RestKit,并在AppDelegate中进行设置。我有一些依赖于
RKObjectManager
singleton的单元测试。这是在AppDelegate中设置的。一些测试专门为测试设置托管对象存储,如下所示。其他人直接对其调用
getObject
etc来测试响应映射

这在我的测试
设置中:

RKObjectManager *mgr = [RKObjectManager sharedManager];
[mgr setManagedObjectStore:managedObjectStore];
这已经成功地工作了很长一段时间

我最近将Cocoapods gem从
0.33.1
更新为最新版本(
0.38.2
),现在,在上面的示例中
mgr
nil
。如果我在上面的第二行中放置断点,
sharedManager
显然会返回一个非nil值,但我的局部变量是nil:

(lldb) po mgr
 nil
(lldb) po [RKObjectManager sharedManager]
<RKObjectManager: 0x7fe9e2d1d5e0>
编辑:我有一个变通方法,它肯定比仅仅为了测试而在AppDelegate上公开属性要好,但我仍然想知道如何避免这样做:

AppDelegate* delegate = (AppDelegate*)([UIApplication sharedApplication].delegate);
NSBundle *appBundle = [NSBundle bundleForClass:[delegate class]];
id objMgr = [appBundle classNamed:@"RKObjectManager"];
[[objMgr sharedManager] setManagedObjectStore:managedObjectStore];

CocoaPods改变了0.36版本中添加依赖项的方式,但总体思路是,它是Swift支持所必需的

我在我的播客文件中添加了CocoaPods 0.36中引入的以下关键字:

使用_框架

我删除了我的目标并改为使用
link\u与
,因此我的播客文件如下所示:

platform :ios, '8.0'

link_with 'Closeout', 'CloseoutTests'
use_frameworks!

pod 'RestKit'
pod 'RestKit/Testing'
pod 'OHHTTPStubs'
... other pods
此外,我必须确保运行RESTKit0.25或更高版本,从而支持框架

pod'RestKit',0.25.0'

最后,我必须修复一系列编译错误:

#导入
变成了
#导入

platform :ios, '8.0'

link_with 'Closeout', 'CloseoutTests'
use_frameworks!

pod 'RestKit'
pod 'RestKit/Testing'
pod 'OHHTTPStubs'
... other pods