0

I am getting an error that this block, which I defined in a header file, has 78 duplicate symbols. I have tried putting it in the precompiled header file but I still get the same results.

This is the error: ld: 34 duplicate symbols for architecture armv7 clang: error: linker command failed with exit code 1 (use -v to see invocation)

It's possible that there are some circular imports, but I can't really change a lot unless anyone has a way to forward define a typedef enum (which I have used all throguhout the project) - something like @class but for typedef.

Can anyone please help?

Dylanthepiguy
  • 1,621
  • 18
  • 47
  • One solution is to declare the enum in its one header file. This way you will never get a circular reference. Also I suggest you use the [NS_ENUM](http://nshipster.com/ns_enum-ns_options/) macro. – rckoenes Dec 18 '14 at 08:51
  • I've tried putting it all in the precompiled header, still no change – Dylanthepiguy Dec 18 '14 at 08:53
  • i made a mistake there, sorry. I edited the post – Dylanthepiguy Dec 18 '14 at 08:56
  • Well i managed to get it down to 14 duplicate symbols by trying to @class more of them. Ill keep doing this, until I give up again. Then ill try that ns_enum thing, although I'm not sure how it'll help. – Dylanthepiguy Dec 18 '14 at 09:28
  • The `NS_ENUm` will not help in your case, but it just is the preferred way of create enums. All I can say is that you should split up the method from the class which is causing the circular import. – rckoenes Dec 18 '14 at 09:30
  • I tried moving it in to the precompiled header, why does that not work? – Dylanthepiguy Dec 18 '14 at 09:31
  • ok i put the block in the m file of where it is needed and it solved my problems – Dylanthepiguy Dec 18 '14 at 10:33
  • Dylanthepiguy - in general, if a line of code _can_ be in a .m file (or a .c, .cpp, .java or what you you), then it _should_ be. These days we rarely have to deal with long compiles, however it will make your header files easier to understand if they have fewer lines in them. Only place in a header file, what really needs to be accessible to two or more .m files. – Mike Crawford Dec 18 '14 at 13:44
  • Yea i understand that, its just that I thought i might need to use it in another file in the future. Now that i think about it, its possible that it may not for now. Thanks for your help. @rckoenes do you want to post your comment as an answer and ill tick it? Also, since i just moved that block out of the .h file, doesn't that mean the circular import is still there, just it doesnt have any effect? – Dylanthepiguy Dec 18 '14 at 20:41

0 Answers0