Search code examples
macosafnetworkingafnetworking-2

Unable to use AFNetworkReachabilityManager class to get network reachability in my OS X project


System i am working is OSX(10.11.1),Xcode (7.2.1) Pod file is placed in the same directory where we have .xcodeproject podfile to include AFNetworking is source 'https://github.com/CocoaPods/Specs.git' platform :osx, '10.9' target 'EntredaUnifyApplet' do pod 'AFNetworking', '~> 2.6' end Runned the following commands pod setup pod install

Aftet that i included below code in my VC and also imported AFNetworkReachabilityManager.m and AFNetworking.h snippet i used is

[[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
    NSLog(@"Reachability: %@", AFStringFromNetworkReachabilityStatus(status));
}];

[[AFNetworkReachabilityManager sharedManager] startMonitoring];

When i try to run it, i am getting below error

Undefined symbols for architecture x86_64: "_AFStringFromNetworkReachabilityStatus", referenced from: ___38-[viewController awakeFromNib]_block_invoke in viewController.o "_OBJC_CLASS_$_AFNetworkReachabilityManager", referenced from: objc-class-ref in viewController.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)


Solution

  • To remove those errors, you need to add systemconfiguration framework and libAFNetworking.a in Build phases under link Binary with Libraries. Then these errors will be removed.