+ Start a Discussion
Justas SerstkovasJustas Serstkovas 

How to access to Reachability in MKNetworkKit-iOS or avoid duplicate symbols with own added Reachability?

Hi All,

I am currently implementing iOS Chatter integration into iPad app. When Salesforce Mobile SDK was added (inlcuding MKNetworkKit-iOS) I got duplicate error on Reachability.o. I understand that we have Reachability added into MKNewtorkKit-iOS, but I also have to have access to it from insdie my project.

Currently I am accessing reachability by adding 
#import "Reachability.h"

If I get read of Reachibility class from my project, I need to gain access to MKNetworkKit-iOS copy of reachability class, but I can't import anything like "MKNetworkKit-iOS/Reachabilty.h" - tried quite a few combination hoping that Xcode autocomplete did not work properly for this library, but no luck.

Currently using Xcode 5.1 with iOS SDK 7.1 and latest Salesfroce Mobile SDK 2.1.1 (all changes pulled today).

Error I am seeing:

duplicate symbol _kReachabilityChangedNotification in:
    /FULL_PATH_TO_BUILD_LOCATION/Build/Intermediates/LDPConference.build/Debug-iphoneos/LDPConference.build/Objects-normal/armv7/Reachability.o
    /FULL_PATH_TO_PROJECT/SalesforceMobileSDK/MKNetworkKit-iOS/libMKNetworkKit-iOS.a(Reachability.o)
duplicate symbol _OBJC_CLASS_$_Reachability in:
    /FULL_PATH_TO_BUILD_LOCATION/Build/Intermediates/LDPConference.build/Debug-iphoneos/LDPConference.build/Objects-normal/armv7/Reachability.o
    /FULL_PATH_TO_PROJECT/SalesforceMobileSDK/MKNetworkKit-iOS/libMKNetworkKit-iOS.a(Reachability.o)
duplicate symbol _OBJC_METACLASS_$_Reachability in:
    /FULL_PATH_TO_BUILD_LOCATION/Build/Intermediates/LDPConference.build/Debug-iphoneos/LDPConference.build/Objects-normal/armv7/Reachability.o
    /FULL_PATH_TO_PROJECT/SalesforceMobileSDK/MKNetworkKit-iOS/libMKNetworkKit-iOS.a(Reachability.o)
ld: 3 duplicate symbols for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)



Thanks a lot of your time looking into this,
J
Best Answer chosen by Justas Serstkovas
Kevin HawkinsKevin Hawkins
Another solution would be to piggyback on the reachability exposed through SFNetworkEngine:

[SFNetworkEngine sharedInstance].reachabilityChangedHandler = ^(SFNetworkStatus newStatus) {
    // Handle your network changes here.
};

That's ultimately leveraging MKNetworkKit's reachability functionality.

All Answers

Justas SerstkovasJustas Serstkovas
I have asked same question on Stackoverflow as well and I got quite a quick answer from redent84:

You can remove any of the two Reachability.m files from the compilation.
Go to Project Settings -> Build Phases -> Compile Sources -> Select Reachability.m -> Delete it.
This won't delete the file from the system, only from the compilation. The header will be used and the implementation won't be duplicated.
You can also rename one of the classes to avoid naming conflicts.


I actually solved the issue.

Please refer to topic on Stackoverflow here: http://stackoverflow.com/questions/22351264/how-to-access-to-reachability-in-mknetworkkit-ios-or-avoid-duplicate-symbols-wit
Kevin HawkinsKevin Hawkins
Another solution would be to piggyback on the reachability exposed through SFNetworkEngine:

[SFNetworkEngine sharedInstance].reachabilityChangedHandler = ^(SFNetworkStatus newStatus) {
    // Handle your network changes here.
};

That's ultimately leveraging MKNetworkKit's reachability functionality.
This was selected as the best answer
Justas SerstkovasJustas Serstkovas
Thanks Kevin, that was the answer I was initially looking for.
J
KlaussKlauss
Hi, 
This is my first attempt at using sf ios sdk and im trying to create an app that will allow users to create a custom object record offline then option to insert when online. I'm trying to piggy back off of the mknetworkkit but can't seem to get it to work. I'm using the ios template app as a start. Instead of going through the login on start up, i have stop at the initalview so that I can change where the user goes depending on network status. This is where I've tried 

[SFNetworkEngine sharedInstance].reachabilityChangedHandler = ^(SFNetworkStatus newStatus) {
    NSLog(@"on/off asdf asd");
};

with no luck. I've also tried subscribing to notification as test but nothing there either. Do I need to initiate something first? Do you have examples on how to implement?

my next step is to fall back on reachability but i would prefer the SF way. Any guidance would be very much appriciated. 

thanks