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..
Related
I'm getting following error after including an external framework and building the project with it. Don't know what to do. Only headers file of the external framework are available to me. All the implementation files (.m) are in a .exe file so I can't access them.
duplicate symbol _OBJC_CLASS_$_AppDelegate in:
/Users/u311107/Library/Developer/Xcode/DerivedData/ConsumerApp-awxafvfmhvwglmdvoobikahakarp/Build/Intermediates/ConsumerApp.build/Debug-iphoneos/ConsumerApp.build/Objects-normal/armv7/AppDelegate.o
/Users/u311107/Desktop/Stash/Mall/consumer/KMCSDK.framework/KMCSDK(AppDelegate.o)
duplicate symbol _OBJC_METACLASS_$_AppDelegate in:
/Users/u311107/Library/Developer/Xcode/DerivedData/ConsumerApp-awxafvfmhvwglmdvoobikahakarp/Build/Intermediates/ConsumerApp.build/Debug-iphoneos/ConsumerApp.build/Objects-normal/armv7/AppDelegate.o
/Users/u311107/Desktop/Stash/Mall/consumer/KMCSDK.framework/KMCSDK(AppDelegate.o)
ld: 2 duplicate symbols for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Please help.
Thanks.
It seems like, KMCSDK.framework has already declared an AppDelegate class, if you can not modify the source code of KMCSDK.framework and rebuild it, you should rename AppDelegate in your project to fix this problem.
I have added the SystemConfiguration framework. I am deploying against targets from 3.2 and higher. Have I forgotten to add something?
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_Reachability", referenced from:
objc-class-ref in AppDelegate.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Okay, the clues are all in the error report you have posted.
While linking (the message is from the linker ld) which occurs after compilation of all the symbols across your project, the message is saying
"In AppDelegate, you have referenced a class object called Reachability"
"_OBJC_CLASS_$_Reachability"
and as far as the linker is concerned Reachability is undefined.
So, check that Reachability is being compiled in your project. The are a couple of ways to do this. Perhaps the most clear way is to
1 select the project file in the navigation pane
2 select the target
3 select Build Phases
4 Expand the Compile Sources section
*Now check the list of sources that will be compiled for your missing class, in your case Reachability.m
If it is missing, use the + button to add the file to the target.
Another way is to
1 select the file you think is not being compiled
2 open the utilities panel
3 select the file inspector tab
There will be a checkbox for each target in your project and you can easily see if your .m file is being compiled for each/all targets or not.
You might have forgotten to include the Reachability classes in your project!
I had a similar problem when I upgraded to the newest version of Mixpanel. The error read:
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_CTTelephonyNetworkInfo", referenced from:
objc-class-ref in Mixpanel.o
You can follow Damo's solution until the last step, and then instead of expanding the Compile Sources section, you have to expand the Link Binary With Libraries section instead, and add the CoreTelephony.framework source which contains CTTelephonyNetworkInfo.
You can read more about the CTTelephonyNetworkInfo class reference on Apple's official website here: http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Reference/CTTelephonyNetworkInfo/Reference/Reference.html
I just marked all of my CocoaAsyncSocket code as non-ARC code, and it's given me these 3 errors:
Undefined symbols for architecture armv7:
"_kCFStreamNetworkServiceTypeVoIP", referenced from:
-[GCDAsyncSocket enableBackgroundingOnSocketWithCaveat:] in GCDAsyncSocket.o
"_kCFStreamNetworkServiceType", referenced from:
-[GCDAsyncSocket enableBackgroundingOnSocketWithCaveat:] in GCDAsyncSocket.o
"_kCFStreamPropertySSLSettings", referenced from:
-[GCDAsyncSocket maybeStartTLS] in GCDAsyncSocket.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Does anybody know what this means and how to fix it?
I think I found the solution to this, by looking in the code comments, but I now see that it's also what Mark Adams suggested above. I had the errors until I added the CFNetwork.framework under Targets->Build Phases->Link Binary With Libraries->Select CFNetwork.framework
It means that some code you are compiling is referencing the constants "kCFStreamNetworkServiceTypeVoIP", "kCFStreamNetworkServiceType", and "kCFStreamPropertySSLSettings", but that those constants weren't found when it tried to link your code with the libraries it uses.
Unfortunately there's a bunch of reasons this could be:
You could have misspelled them
They could be #ifdef'd out for that architecture
You might not be linking the correct librar(y, ies)
They could be marked as having 'hidden' visibility so that they can only be used in the declaring library
Probably other reasons
You can use 'nm' to poke at the exported symbols from the binary of a library, and 'otool -L' to check which libraries your binary is linking.
I had this same error when integrating LineaPro API into an app.
The fix i implemented was adding ExternalAccessory.framework to General -> Linked Framework and Libraries.
I already had CFNetwork.framework included.
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.
From what I have read this is supposed to be when the linker (not exactly sure how that works) can't find a symbol. the symbol in question is: SCNetworkReachabilityCreateWithAddress as can be seen from the full error message below.
the thing is that the correct
framework is added to my target.
xcode recognises the symbol OK, i.e.
there is no error message in the .m
file.
the .m file is added to the correct
target so I'm not at all sure what to
do.
Any ideas please?
"SCNetworkReachabilityCreateWithAddress", referenced from:
-[AppWelcomeVC viewDidLoad] in AppWelcomeVC.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
Do you have #import <Availability.h> in your AppWelcomeVC class header, or added to your precompiled header (MyApp_Prefix.pch)?
What frameworks do you have in your project?
In the past when I've had this error removing the framework and readding it fixed the problem.
Permissions problems with the framework file itself can also cause this error.