RestKit with cocoapod with use_frameworks! can't use AFNetworkReachability

独自空忆成欢 提交于 2019-12-06 05:56:19

问题


My pod file looks like this:

source 'https://github.com/CocoaPods/Specs.git'

platform :ios, '8.0'
use_frameworks!

pod 'RestKit'
pod 'CocoaLumberjack'

On top of my App delegate I added:

#import <RestKit/RestKit.h>

In the application:didFinishLaunchingWithOptions: I added this:

RKObjectMapping *mapping = [RKObjectMapping mappingForClass:[NSString class]];

So far it compiles fine, then I added:

AFHTTPClient* client = [[AFHTTPClient alloc] initWithBaseURL:[[NSURL alloc] initWithString:@"asdf"]];

Again, works fine, then I tried the reachability:

[client setReachabilityStatusChangeBlock: ^(AFNetworkReachabilityStatus status)
     {
         NSLog(@"Reachability status changed");
     }];

Unfortunately, this fails to compile and gives the following error:

no visible @interface for 'AFHTTPClient' declares the selector 'setReachabilityStatusChangeBlock:'

I went to check why that might be, and found that the compilation of this method is guarded by _SYSTEMCONFIGURATION_H macro, which for some reason resolves to false in this case. I tried to link my project against the SystemConfiguration framework, but it doesn't help. My assumption is that the RestKit should be linked with it at compile time, and when I checked the RestKit pod, the SystemConfiguration is indeed present in the Link Binary with Libraries phase. Any ideas why this doesn't work?

Xcode7b5, cocoapods 0.38.2 Sample project can be found here.

来源:https://stackoverflow.com/questions/31939494/restkit-with-cocoapod-with-use-frameworks-cant-use-afnetworkreachability

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!