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?
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.
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.
Related
I am creating an iPhone application, and I am using RestKit api to connect to the server. I am facing a problem whenever I add the Reachability.m and Reachability.h into the second UIViewController of the project. I tried making a new .m file in Xcode4 and now I get an Apple macho-linker (id) error on all tabst. I added it to the first UIViewcontroller it works normally, but when I try to add it to any other forms I receive this error.
Have you added the SystemsConfigurations.Framework to your project? Apples reachability package requires the SystemConfigurations.Framework to be added before it can be used.
Also if you are using ARC (Automatic ReferenceCounting), ensure you have disabled ARC for that particular file. Do this by going to build phases, compile sources, then double clicking Reachability.m and entering -fno-objc-arc to disable ARC
Solved it by importing ONLY "Reachability.h" not "Reachability.h" and "Reachability.m"
Try adding CFNetwork.framework.
I added add .h and .m files from an non ARC application to ARC iphone Application. I set -fno-objc-arc as compilerflag in build phases to these files. But when I try running this application after adding these files I am facing a problem. Application does not give any error is just shows failed once and stops the process of building.
I am confused and trying to understand what is the problem in this. After I delete these non ARC files, it is running normally.
First, you add the .h file but don't set any compile flag on it - your comment on this is a bit confusing - in fact your question and comments are confusing. So lets try to sort this out:
you added both the .m and the .h to your project - you can see them in the left pane
the .m file was added to the build phase of the desired target with a compile flag of -fno-objc-arc
Now it gets tricky, as your question is self contradictory:
1) you tried to build and the build failed. So then edit your post and provide the error messages.
2) the build succeeded, you ran the project, but it failed somehow. Problem is you don't tell us how it failed.
So, in addition to clarify your question, please note that if you add a non-ARC file to your project, that file must conform to certain conventions, which you can read about in the ARC docs (two very short articles, one from Apple, one from llvm). For instance, if you have a method in that file that starts with "init" or "create" then whatever object it returns must be retained not autoreleased.
I personally have used non-ARC files with an ARC project for a year now with no problems.
Just do the following thing:
Reset your simulator.
2 . Clear your Build
in your non arc file content remove the release,retain,autoreleasepool and auto release.
After build and run. hope it will work.
I am trying to integrate dejalactivityview indicator view in my application, and I am running into this error:
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_DejalActivityView", referenced from:
objc-class-ref in WelcomeMessage.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
This library is pretty easy to integrate and I am pretty sure I did everything correctly: added the .m and .h files, my project is ARC enabled and thats how I call the method:
[DejalActivityView activityViewForView:self.view];
Pretty simple, no? Still doesn't work...thanks for the help!
UPDATE:
I tried this:
DejalActivityView *testvc;
[testvc activityViewForView:self.view];
But I am getting an error (before compiling) that "no visible #interface for "DejalActivityView" declares selector 'activityViewForView:self.view'"
OK, I got the same thing just now. It seems if you simply drag the .m and .h files into your project, the .m file won't be added as source to link to your project, hence the link errors. What solved this for me was adding the DejalActivityView.m source file into the "Compile Sources" section under "Build Phases" of the project target. In other words, go to the Project Navigator and click on the uppermost item, then select the "Build Phases" tab, and then add the .m file to the "Compile Sources" section. Build and run your project again, and this time it should not have the linker errors!
what's your class name? make sure u spell correctly if again not work then change the class name. cz it some times that your class name matches with some built in name or some method name in project already in use
Check if you have actually copied the .m and .h files or you are just referencing them. Compiler might not be able to compile these files if you have not copied them to your project folder.
check this for
"no visible #interface for "DejalActivityView" declares selector 'activityViewForView:self.view'"
reply:- No need for a property for the DejalActivityView
please import this file in your viewcontroller .m
#import "DejalActivityView.h"
and write this code in viewdidload and check
[DejalActivityView activityViewForView:self.view];
if you have any error after that implement the download this from this link and implement , i use and work my code
recently I've been given a project which need to display a spherical panorama view. Normally on iphone i've been using panoramaGL for some time but for ipad, i dont have any luck to use it any more.
I can compile the lib with some minor warnings. but when i try to link the lib to my real project, it just keep telling me that PLTexture is not there. it says
Undefined symbols:
"_OBJC_CLASS_$_PLTexture", referenced from:
objc-class-ref-to-PLTexture in panoTestViewController.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
Please anybody can help me out of this?
I had the same problem, and noticed that although I included PanoramaGL xcode project, its lib (libPanoramaGL.a) was not selected to build with the target (that little checkbox in the top right list of XCode).
Once I selected the checkbox, the problem went away, but the bulider was stuck on a similar error with PLResources as the current trouble maker. But this might be only my problem, cause I went to the PanoramaGL project, and noticed that PLResources.c and .h were not included in the project.
Once I included them and rebuilt everything - the build succeeded.
Hope this helps,
Oded.
I'm getting the following error in Xcode 3.2.1 on Snow Leopard 10.6.2 whenever I try to compile any iPhone application generated by Appcelerator Titanium. However, the build error only appears when I select iPhone simulator on the architecture menu and if I select the iPhone device, I am able to run the app on my device .
Further more, the iPhone simulator launches successfully and executes the program directly from the Titanium environment which uses Xcode to build .
Why is this happening ?
ld: duplicate symbol _main in Resources/libTitanium.a(main.o) and /Users/prithviraj/Documents/project/Final/build/iphone/build/Final.build/Debug-iphonesimulator/Final.build/Objects-normal/i386/main.o
collect2: ld returned 1 exit status
Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 failed with exit code 1
I can't tell you why this is happening, but I can suggest a workaround. When I commented out the entire contents of the main.m file that was generated for my Titanium project, I was able to compile successfully and run on the Simulator. Let me know if that works for you.
Check to see if you have multiple declarations of main function in your project.
I just spent a couple hours battling this one. It was because I was using the -all_load linker flag. If you are using that flag to get around the category bug, there are some other solutions -- see here.
I had a similar problem. A unit test class was accidentally included in my build. If you search your project for "main(" you'll probably find the duplicate functions.
This happened to me for 2 reasons:
1: Class A calls class B and both had imported the same class. Fix it by importing the class in .m file.
2: Two classes have a constant with the same name (even if the constant is defined in the .m file). Fix it by changing the name of the constants.
I had this problem because I define a file as such:
#UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
...
}
And also had a file main.m:
int main(int argc, char* argv[])
{
#autoreleasepool {
int retVal = UIApplicationMain(argc, argv, nil, #"AppDelegate");
return retVal;
}
}
Seems as though there are multiple ways to get into this state. Mine was different. I read a hint where you could drag from a .xib event selector into the .h implementation of your view controller and it would auto-gen your methods. It did - which was cool. I immediately started getting duplicate symbol errors - which was not cool.
I did not have time to dig deep into the linker to see what happened. I created a new view controller, copied the context of my old .xib into the new guy. Deleted the old .h, .m and .xib and built and it worked again. Very odd, very annoying time waste.
There is obviously some bug with this xcode "convenience".
I found this happened when i had an implementation file with a main function in it (say abc.m) and also had another main.m. Once I commented out the main function in abc.m, the project compiled successfully.
Based off what I can tell from these other answers, I'm going to need to be remove a bunch of main methods.
But to do that easily I first need to remove all the gd comments from my files because they are assiduously documented with comments at nearly every other line
This regular expression matches all C multi-line comments including their delimeters & may help you on your journey
/\*((?!\*/).)*\*/
I spent more than an hour in searching for a correct answer but nothing worked for me.
Finally the xcode it self telling something is duplicated, so go to that particular folder(in this case: /Users/prithviraj/Documents/project/Final/build/iphone/build/Final.build/Debug-iphonesimulator/Final.build/Objects-normal/i386/main.o) and delete all the files and also check same in your project whether that particular class/interface is declared twice if yes delete it.
After deletion clean and run the project.
It worked for me hope this helps(-_-).
Delete /Users/{username}/Library/Developer/Xcode/DerivedData folder and build again.