Issue with Duplicate symbol in link phase of project build in Xcode - iphone

I've been building a game application for iOS. The application was working fairly well, but I've done a fairly large restructure today to be a little more model-view-controller 'compliant'.
I've built the main game engine in C++, but use Objective-C for managing the viewControllers, views etc.
Now, when I compile the project, I'm getting an error in the link phase. Details are below:
ld: duplicate symbol ApplicationEngine::OnFingerUp(Vector2) in /Users/Dan/Library/Developer/Xcode/DerivedData/BlackHoles-exrlidtstxzdtsbyjghgquhlsqul/Build/Intermediates/BlackHoles.build/Debug-iphonesimulator/BlackHoles.build/Objects-normal/i386/ApplicationEngine.o and /Users/Dan/Library/Developer/Xcode/DerivedData/BlackHoles-exrlidtstxzdtsbyjghgquhlsqul/Build/Intermediates/BlackHoles.build/Debug-iphonesimulator/BlackHoles.build/Objects-normal/i386/AppDelegate.o for architecture i386
collect2: ld returned 1 exit status
Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/g++-4.2 failed with exit code 1
OnFingerUp is a function within my C++ ApplicationEngine, and gets called from the viewController.
Is the problem likely to be caused by some confusion in my #includes / #imports?
My AppDelegate file needs to #include a MainViewController file to set up the initial viewController. The MainViewController in turn #includes the ApplicationEngine file to instantiate that class. ApplicationEngine contains the OnFingerUp method. The OnFingerUp method is then called from MainViewController when I get a touch input. Could this sequence of includes be causing the duplicate?
I've noticed that if I temporarily remove the OnFingerUp method from the app completely, then I get the same issue with another method within the ApplicationEngine.
There aren't any errors or warnings as the individual files compile. I've also tried to Clean All and recompile, but no joy.
Does anyone have any suggestions as to how I could approach solving the issue? Thanks, Dan.

I can think of 3 causes for this: 1) Accidentally #including a .cpp file, 2) forgetting #ifndef guards in the header file, 3) forgetting inline when writing the method definition in a header file.

Related

How to trace a fatal error with Xcode and Swift?

I am trying to test a simple a program I have made while learning swift programming, but I always get a fatal error, and nothing will be shown.
I tried to copy my code to a playground, but there the custom classes I created are not recognized?
I found the error that one of the buttons is referencing the wrong outlet. This outlet was created by mistake, and it is name is the same as one of the Actions.

ARC Semantic Issue: No visible #interface for Class declares the selector

Pretty basic stuff but i am unable to troubleshoot where the problem is. In my project, i have a class named "TheFeedStore" with following two methods:
- (BOOL)hasItemBeenRead:(RSSItem *)item
{
............
}
- (void)markItemAsRead:(RSSItem *)item
{
.........
}
I am using the following class method so other classes can access these methods using it:
+ (TheFeedStore *) sharedStore
{
static TheFeedStore *feedStore = nil;
if (!feedStore) {
feedStore = [[TheFeedStore alloc] init];
}
return feedStore;
}
In one of my another class, i can easily access the above methods by writing
if ([[TheFeedStore sharedStore] hasItemBeenRead:item])
or
[[TheFeedStore sharedStore] markItemAsRead:entry];
But in another class if i try to access these methods in a similar manner, i get the error "No visible #interface for 'TheFeedStore' declares the selector 'hasItemBeenRead:"
1) I have imported TheFeedStore.h file in the classes from i am
accessing these methods of TheFeedStore class.
2) I have checked like 10 times and there is no typo.
3) The methods i am accessing are also declared in the header file of
TheFeedStore.h
UPDATE: Just to check, i have declared another test method in TheFeedStore.h, same result, one class can access the newly created method while rest of the three classes cannot.
UPDATE: I have tried creating more methods in the TheFeedStore.h just for troubleshooting this issue. The new methods are also not accessible from the other classes. But if the return type of these new methods is (RSSChannel*) which is another model class in my project, than they become accessible. If their return type is other than some class like (void) and (BOOL) then they are not accessible. Here is my TheFeedStore.h https://gist.github.com/jessicamoore112/5558473
You have said that you are using #class instead of #import in your header files, the methods that you are trying to access are declared in the header files and there are no typos of any kind.
In such cases, usually no body points this issue but i am going to do it anyway because i have faced such issues many times. You have probably created many copies of your project to work on each functionality and also keeping a working project.
When you do this, sometimes Xcode is still using the older copies of few files. That means it is still using the older copy of the TheFeedStore.h when the methods you are trying to access were not declared by you.
How to solve this problem is very simple. Go to the file from which you are trying to access the methods and the files in which these methods are declared.
In the Utilities section on the right hand side, check the location and full path under "Identity and Type" area.
First check the names of the project, if it is different from the project name that you are working on, that means Xcode is still pulling the old copies of the files from the previous revision of your project. See the blue arrows where the project name is 13SampleMoreRequests in my case.
If this name is same as your project name, then my answer does not solve your problem. If its different, you should use the new copies of the file by browsing the new location using the sign that is pointed out by red arrow.
Once you browse and use the new files, your problem will be solved and you will be able to access the methods. If you still can't, copy these files, delete from the project and then add them again and you won't face this problem.
Hope this helps!
Cyclical imports, e.g. A.h imports B.h while also B.h imports A.h is the most common problem.
In C, cyclical imports won't work and one of the imports will be silently ignored. Make sure you are not having a cyclical import. If you do, solve it (e.g. using forward declarations).
Import problems can be also easily inspected if you generate the preprocessed output (you can find it in one of the Xcode menus).
That might sound silly, but I have similar cases once in a while and sometimes just simple quitting and starting xcode helps, it tends to stuck sometimes.
Also, sometimes cleaning the project helps.
'Cause I have very similar to yours singleton code and it works fine.
Guys I had encountered the exact same issues. After some searching on SO and the search engine I was able to solve it.
In my Case I have four files:
RadioStation.h
RadioStation.m
ViewController.h
ViewController.m
My mistake was to place all my methods in RadioStation.m and only put my variables on radioStation.h
So when I import radioSation.h on my ViewController.m and try to define methods for button-click on my app that's where the problems started.
I got the error/warnings "ARC Semantic Issue: No visible #interface for Class declares the selector" every time I built or ran the app simulator.
My Solution was to go back to RadioStation.h file and just declare all my methods there.
Since they were already defined on RadioStation.m I was good to go.
So make sure you have properly declared your methods on the file that is going to be imported on your viewControllers.
Hope that helps.
In my case I had some very strange path entries in
Framework Search Paths
Library Search Path
(Targets -> YOUR_APP_NAME -> Build Settings in "Search Paths" section)
I removed them and the error messages are gone.

Integrate auriotouch in another app

excuse me to create again this question, but I have another problem. I'm trying to integrate the aurioTouch Apple sample in my app. I have put all the code that was in aurioTouchAppDelegate in my app delegate file. The code runs, but some methods, like methods in EAGView file doesn't run, I don't know whym they are not called.
Some help or hints are welcome...
Have you integrate all the setting from Project's Build Settings. Actually I had the same issue but then I compare all the settings from Build Settings and found that some of the Linker flags were creating the problem and then was able to solve the problem. So whenever you have such problems try to go to Project's Build setting and compare all the keys. Mostly the Linker flags creates the problem in such cases.... hope this help to others also...
EDIT
After referring to your project. Notice that you have overloaded the property view of ViewController with your custom View EAGLView. You have not separated customView and ViewController's view.
Also, one major thing is you have to Initialize your EAGLView and add it to your ViewController's view. and rest of the things will go on in EAGLView.

Iphone compile warning

im compiling my app , which is working great and i wanted to ask you 2 questions
1. im getting about 14 warnings like that
no '-addCategory' method found
which i know how to solve but even after i cleaned everything added the function to the header file and compile again it's still there i cant get rid of it.
2. im pretty new in coding and the code is not GREAT but it's ok how do i know apple will accept it ?
thank you very much !!
Declare that method in .h file
Implement that method in .m [implementor of .h] file .with the same signature.
Clean in once.
And try..
It should work..!

/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 failed with exit code 1 error [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
gcc-4.2 failed with exit code 1 iphone
I am getting the error
Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 failed with exit code 1
every time I try to run the program on the iPhone device and the Simulator.
I am also seeing this:
ld: duplicate symbol .objc_class_name_MainView in /Volumes/Mark's Flash Drive/iFtB/build/iFtB.build/Debug-iphonesimulator/iFtB.build/Objects-normal/i386/MainView.o and /Volumes/Mark's Flash Drive/iFtB/build/iFtB.build/Debug-iphonesimulator/iFtB.build/Objects-normal/i386/iFtBAppDelegate.o
too. Could this be part of the problem?
Thanks in advance,
Mr. Man
It means the MainView class is defined twice or more.
Check:
If the MainView class's #implementation appears in any .h files. It shouldn't.
If there are 2 MainView classes define by you and a third-party library. You may need to rename your MainView class.
As KennyTM is correct.
I accidentally imported the .m file instead of the .h an received this lovely error.
I had this same problem when i add Reliability class to my code. I already included tree20 to my project which is having reliability class. So when I add the reliability class again to my class I got the same error. I removed the Reliability code from my project and it works perfect.