0

I have a defines.h file with following code

    typedef enum AnswerType : NSUInteger {
    kAnswerTypeNotResponded = 0,
    kAnswerTypeYes = 1,
    kAnswerTypeNo = 2,
    kAnswerTypeComplain = 3
} AnswerType;

When I import this file in several other files - I get an error

ld: 13 duplicate symbols for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I need AnswerType be visible in many places. What is the best variant to implement it?

Mykyta Karpyshyn
  • 198
  • 2
  • 13
  • Are the duplicate symbols related to this enum or something else? Most likely you have constants in the .h that weren't properly marked as `extern`. – rmaddy Jan 01 '16 at 23:40
  • Update your question with some examples of the duplicate symbols and their corresponding declaration in the .h file. – rmaddy Jan 01 '16 at 23:42
  • Hey you can see my answer for your exact solution : https://stackoverflow.com/a/38762225/1733922 – Kalpesh Panchasara Aug 07 '17 at 11:11

2 Answers2

1

Your enum looks fine. However, I guess there should be another problem.

One of the major reason for occurrence of this issue is that you might have a file listed in build phases more then once. So you need to make sure that files are listed in build phases only once.

Here are the steps you can follow:

  1. Check Build phases in Target settings.
  2. Check if any file exists twice.
  3. If file exist twice delete one. If not delete file in the bottom which is the latest one.
  4. Build again.

Original source of answer

Community
  • 1
  • 1
BLC
  • 2,240
  • 25
  • 27
1

Just follow below steps and your issue is solved.

1. Go to Build Setting

2. Search for No Common Blocks and

3. Set it NO

4. Build again

5. You will not get this error again.

Kalpesh Panchasara
  • 1,730
  • 2
  • 15
  • 27