iPhone - Using Reachability throwing duplicate symbol _OBJC_IVAR error
Asked Answered
P

2

6

I have added the Apple Reachability files to my project and I am already getting errors. I have NOT even added these files to any of my classes, only added them to my project. How could I already be getting this error?

When compiling I get the following error:

ld: duplicate symbol _OBJC_IVAR_$_Reachability.localWiFiRef in /Users/webmaster/Dropbox/iPhone-Development/Official-Projects/PUC/build/PUC.build/Debug-iphonesimulator/PUC.build/Objects-normal/i386/Reachability-B40F6D608A62C635.o and /Users/webmaster/Dropbox/iPhone-Development/Official-Projects/PUC/build/PUC.build/Debug-iphonesimulator/PUC.build/Objects-normal/i386/Reachability-823B59DA9A9B0D23.o
collect2: ld returned 1 exit status
Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 failed with exit code 1

Note: I am using the Three20 project, so I am not sure if it could be conflicting somehow?

Pasteurism answered 3/2, 2011 at 18:8 Comment(0)
P
8

So, I figured it out. I realized that since I am using ShareKit, it also includes Reachability, so it WAS in my project twice, I just didn't realize it.

Pasteurism answered 3/2, 2011 at 18:41 Comment(1)
Cheers, was stuck on this and was sure I hadn't used ReachabilityWeightless
K
0

You need to #import your custom class's .h in your .m. Otherwise the #import "Reachability.h" is happening twice and, I'm guessing, there is a variable called localWiFiRef defined in Reachability.h that now is beind declared twice and hence the "duplicated symbol" error.

When doing that, you will not need to #import "Reachability.h" in the .m.

Kuomintang answered 3/2, 2011 at 18:19 Comment(4)
I was doing that, I just didn't post it here. So, it seems that I still get this error even when I don't include any reachability files into my class...Pasteurism
Is "Reachability.h" imported anyplace else?Kuomintang
Remove all references to the Reachability files, and only have them sitting in my project. Still same error.Pasteurism
I figured it out. I was using ShareKit which had already included Reachability, I just didn't realize it.Pasteurism

© 2022 - 2024 — McMap. All rights reserved.