objective-ctypedefduplicate-symbol

typedef in separate header file


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?


Solution

  • 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