I am trying to use Reachability in ios 5.1 but it gives me a Match-o Linker error.
I am using Xcode 4.3 and building my app with armv6 and armv7. I have read that Reachability doesn't play nice with armv7, which may be causing the error. Is that true?
If so, is ythere any workaround to get my app checking internet connectivity?
And yes, i have imported both
Reachability.h
and
SystemConfiguration.framework
My sample implementation code is as below:
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(checkNetworkStatus:) name:kReachabilityChangedNotification object:nil];
internetReachable = [Reachability reachabilityForInternetConnection];
[internetReachable startNotifier];
hostReachable = [Reachability reachabilityWithHostName: #"www.apple.com"];
[hostReachable startNotifier];
Thanks in advcance!
https://github.com/tonymillion/Reachability
iOS5 / GCD / ARC friendly version
Not sure whether you have solved this problem yet.
But if you read the actual error highlighted in Xcode 4 and if it says something like
"ld: duplicate symbol _OBJC_IVAR_$_Reachability.reachabilityRef in . . . linker command failed with exit code 1 (use -v to see invocation)"
That is saying you have already included Reachability.h and Reachability.m in your project somewhere and you now have included a duplicate copy.
Delete all the duplicate copies of Reachability.h and Reachability.m and leave just 1 copy of it somewhere in your project files.
Related
I'm looking for some advice on calling C# methods from Objective-C on the iPhone. I've read the instructions at http://www.mono-project.com/Embedding_Mono along with numerous stackoverflow threads, but I'm still having problems. I can get everything to work on the simulator, but not on a device. At first, the call to mono_jit_init() failed with an assertion in one of the trampoline functions. Eventually I discovered that I had to do the following before calling mono_jit_init():
const char *path = [[[NSBundle mainBundle] bundlePath] UTF8String];
setenv("MONO_PATH", path, 1);
mono_jit_set_aot_only(YES);
Unfortunately, now I get the following error:
Failed to load AOT module '/private/var/mobile/Applications/DD55C2F7-A692-4E68-B4DB-927690F9F3F2/DummyTest.app/mscorlib.dll.dylib' in aot-only mode.
Here's what I've done so far:
Run mtouch as follows:
/Developer/MonoTouch/usr/bin/mtouch --xcode=dummy --fat DummyLib.dll
Note: This did not generate a main.m files as described in the documentation.
Copied the resulting DummyLib.dll, mscorlib.dll and DummyLib.dll.7.s files into my xcode project.
Added the following line to the "Header Search Paths" line in my xcode project configuration
/Developer/MonoTouch/SDKs/MonoTouch.iphoneos.sdk/usr/include
Added the following lines to the "Other C Flags" line in my xcode project configuration
-D_THREAD_SAFE
-DNS_BLOCK_ASSERTIONS=1 -D_THREAD_SAFE
Added the following line to the "Other Linker Flags" line in my xcode project configuration
-L/Developer/MonoTouch/SDKs/MonoTouch.iphoneos.sdk/usr/lib -lmono-2.0 -lpthread -liconv
Compiled and run my xcode project.
I'm sure I must be doing something wrong or I've missed a step somewhere, because other people claim to have this working. Does anybody have any idea what I've done wrong?
I am having some problems adding Reachability to my project. I just used Reachability before, but this time I am failing. I always having the error below:
Undefined symbols for architecture armv7:
"_OBJC_CLASS_$_Reachability", referenced from:
objc-class-ref in DelegatePrincipal.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
My project don't use ARC (and I don't want it), base sdk 5.0, ARchitecture standard (armv7) and I already add the SystemConfiguration.framework.
I also tested the Tony million Reachability and it does not work. Same problem.
I saw the same question from other topics, but it was with ARC. My project does not have ARC.
Additionally, i am doing a simple test inside the delegate, as follows:
Reachability *reach = [Reachability reachabilityForInternetConnection];
NetworkStatus netStatus = [reach currentReachabilityStatus];
if (!netStatus == NotReachable) {
NSLog(#"Not connected");
}
Thanks!
Are you sure you added the Reachability.m file to your project?
Check also if it is assigned to your current target.
That error definitely means that the linker did not find the class definition anywhere among the binaries produced by the compiler for the armv7 architecture.
Add Message UI framework in your project..
Hope, this will help you...enjoy..
Reachability *r = [Reachability reachabilityWithHostName:#"www.google.com"];
This line works fine on device, but on simulator i get crash :
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[Reachability reachabilityWithHostName:]: unrecognized selector sent to class
Does anyone know why ?
I had almost the same problem, except that linker did not link Reachability after I added it via pod.
internetReachable = [Reachability reachabilityWithHostName:#"www.google.com"];
In this line compiler was giving error 'No known class method for selector reachabilityWithHostName:'.
I tried to readd reachability, tried to clean project, nothing helped. Then I just tried to rewrite this line and it compiled!
internetReachable = [Reachability reachabilityWithHostname:#"www.google.com"];
And now I understand why it worked. Because my old code was taken from another project with other version of Reachability and selector was with 'HostName' but new one is with 'Hostname'.
Before rewriting I was checking if Reachability has this method and it seemed to me that it has and I couldn't understand the problem. It turned out that I didn't notice this small change in one letter!
solved, I was upgrading Reachability, I searched the web and I found that somewhere someone had this before and just delete systemconfiguration framework and re add it, clean the project and then build again and it will work on both simulator and device perfectly
Got this error for the first time, I have looked around and cannot find a solution to help me, I have cleaned my build and also checked to make sure I am compiling for the latest firmware.
This happened after I tired implementing a reachability solution I found over here
I imported the two reachability files (.m/.h) then added this code into the .m file and delared t in the . h of the reachability files
-(BOOL)reachable {
Reachability*r =[Reachability reachabilityWithHostName:#"enbr.co.cc"];
NetworkStatus internetStatus =[r currentReachabilityStatus];
if(internetStatus ==NotReachable){
return NO;
}
return YES;}
After that I called the function from both of my viwcontrollers viewwillappear methods like so..
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
//-- Check Reachability START ---->
Reachability *reach = [[Reachability alloc] init];
if ([reach reachable]) {
NSLog(#"Reachable");
}
else {
NSLog(#"Not Reachable");
}
//-- Check Reachability END ---->
}
No errors were produced untill I tried to build and run in the simulator. This is the error I received :(
Ld
/Users/imac/Library/Developer/Xcode/DerivedData/wizcode-ccyrqptvfsabmbahgxartbvxwurq/Build/Products/Debug-iphonesimulator/wizcode.app/wizcode
normal i386
cd "/Users/imac/Documents/Iphone
applications/wizsanCode/wizsanCode.5/wizcode"
setenv MACOSX_DEPLOYMENT_TARGET 10.6
setenv PATH
"/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/llvm-gcc-4.2
-arch i386 -isysroot
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk
-L/Users/imac/Library/Developer/Xcode/DerivedData/wizcode-ccyrqptvfsabmbahgxartbvxwurq/Build/Products/Debug-iphonesimulator
-F/Users/imac/Library/Developer/Xcode/DerivedData/wizcode-ccyrqptvfsabmbahgxartbvxwurq/Build/Products/Debug-iphonesimulator
-filelist
/Users/imac/Library/Developer/Xcode/DerivedData/wizcode-ccyrqptvfsabmbahgxartbvxwurq/Build/Intermediates/wizcode.build/Debug-iphonesimulator/wizcode.build/Objects-normal/i386/wizcode.LinkFileList
-mmacosx-version-min=10.6 -Xlinker -objc_abi_version -Xlinker 2 -lz
-framework CoreGraphics -framework MobileCoreServices -framework
SystemConfiguration -framework CFNetwork -framework UIKit -framework
Foundation -o
/Users/imac/Library/Developer/Xcode/DerivedData/wizcode-ccyrqptvfsabmbahgxartbvxwurq/Build/Products/Debug-iphonesimulator/wizcode.app/wizcode
ld: duplicate symbol _OBJC_IVAR_$_Reachability.reachabilityRef in
/Users/imac/Library/Developer/Xcode/DerivedData/wizcode-ccyrqptvfsabmbahgxartbvxwurq/Build/Intermediates/wizcode.build/Debug-iphonesimulator/wizcode.build/Objects-normal/i386/Reachability-183E2D17A6B26176.o
and
/Users/imac/Library/Developer/Xcode/DerivedData/wizcode-ccyrqptvfsabmbahgxartbvxwurq/Build/Intermediates/wizcode.build/Debug-iphonesimulator/wizcode.build/Objects-normal/i386/Reachability-183E2D17A6B26176.o
for architecture i386 collect2: ld returned 1 exit status Command
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/llvm-gcc-4.2
failed with exit code 1 ld: duplicate symbol
_OBJC_IVAR_$_Reachability.reachabilityRef in
/Users/imac/Library/Developer/Xcode/DerivedData/wizcode-ccyrqptvfsabmbahgxartbvxwurq/Build/Intermediates/wizcode.build/Debug-iphonesimulator/wizcode.build/Objects-normal/i386/Reachability-183E2D17A6B26176.o
and
/Users/imac/Library/Developer/Xcode/DerivedData/wizcode-ccyrqptvfsabmbahgxartbvxwurq/Build/Intermediates/wizcode.build/Debug-iphonesimulator/wizcode.build/Objects-normal/i386/Reachability-183E2D17A6B26176.o
for architecture i386
Command
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/llvm-gcc-4.2
failed with exit code 1
So, the problem has been resolved.
What happened was when I imported the reachability files over into my build something funny was happening and somehow I deleted the reachability files that were already in my build being used by the "all seeing I" ASIHTTPRequest methods I was using for transporting my data... which messed everything up.
So long story short I replaced the files and everything is working fine and I also found out that ASIHTTPTequest is taking care of the reachability for me :) how cool is that.
Check if SystemConfiguration is linked properly. Anyway, clean up your code:
+ (BOOL)reachable {
Reachability *r = [Reachability reachabilityWithHostName:#"enbr.co.cc"];
NetworkStatus internetStatus = [r currentReachabilityStatus];
return internetStatus != NotReachable;
}
And then just call [Reachability reachable] wherever you need. This also fixes a memory leak you have.
Just to add to this, it happened me after I regenerated managed subclasses and it didn't actually overwrite the existing ones but just made new duplicates. I just deleted both and regenerated and it was all good.
After modifying my core data model, I deleted all the (auto generated) NSManagedObjectModel subclasses, and created them again. Once they all were created, I dragged them to a Group folder in XCode... and got the spinning beachball for longer than usual.
The next time I tried to run, it failed with the "Mach-O-Linker" (Id) Error. After reading other responses, I figured it might have something to do with the NSMObj classes not being where expected. I deleted them, quit, opened, generated them, and put them in their customary group folder... and Viola! no Mach-O error.
I see that the problem is resolved, but I post this just to index it under the proper question. In my case, deleting and regenerating (via editor menu) the managed object subclasses fixed the issue.
Remove it then add it again. Works for me. :D
This happens with me when i am adding third party analytics framework in my project. When i check with the info of framework its not properly copied on disk. i download new framework and copied it into project and now there is no error.
I had this code in one of my UIViewController and removing it solved this bug. What a stupid and not-clear-at-all error message
NS_ENUM(NSInteger, Mode) {
Assessments = 0,
Onboarding
};
Make sure you are running YourApp.xcworkspace instead of .xcodeproj file. I did face the same issue when did run .xcodeproj file. Running .xcworkspace has solved the problem and the error has gone away.
I downloaded OpenFeint version 2.3.1, unzipped and placed the OpenFeint folder inside right underneath my project in Xcode, and checked "recursively create groups if needed" (the instructions said to use groups and not a folder reference).
I renamed my AppViewController and AppDelegate .m files to .mm. I followed the rest of the instructions and compiled and ran, the app works fine.
Inside AppViewController.mm I do:
#import "OpeinFeint.h"
and compile, which gives me the errors:
#error: "OpenFeint requires Objective-C++. In Xcode, you can enable this by changing your file's extension to .mm".
#error: syntax error before 'OfNotificationCategory'
#error: syntax error before 'OfNotificationCategory'
and the location of the errors takes me to the OpenFeint files.
I did add -ObjC to Other Linker Flags and check Call C++ Default Ctors/Dtors in Objective-C.
Any advice? Thanks!
The linker flag should be -lobjc, not -ObjC.