duplicate symbols for architecture i386 clang

后端 未结 24 1061
悲哀的现实
悲哀的现实 2020-11-29 20:33

I\'ve seen several posts on google and stackoverflow related to this error, I\'ve read all of them but still fetching the problem , I will be glad for a solution. Here is th

相关标签:
24条回答
  • 2020-11-29 21:03

    I imported files from another project, it had main.m file as well. So overall I had two main.m files, deleting one resolved the issue for me.

    0 讨论(0)
  • 2020-11-29 21:04

    Just to add to the possible solutions.

    In my case I had accidentally declared and initialized a variable in a header file.

    For example this is wrong:

    MyFile.h

    #import <Foundation/Foundation.h>
    
    NSInteger const ABCMyConstant = 6;
    

    It should be:

    MyFile.h

    #import <Foundation/Foundation.h>
    
    NSInteger const ABCMyConstant;
    

    MyFile.m

    #import "MyFile.h"
    
    NSInteger const ABCMyConstant = 6;
    
    0 讨论(0)
  • 2020-11-29 21:04

    I got this error when I had a static library included in the main project while also including a second library that also had a reference to the library. That's pretty confusing, so maybe this is clearer.

    MyWorkspace + Main Project + Reference to library 1 + Reference to library 2 + Library 1 + Library 2 + Reference to library 1

    I removed the reference to library 1 from the main project and the error went away.

    0 讨论(0)
  • 2020-11-29 21:08

    I tried cleaning the project, erased all derived data. Nothing worked. Atlas, this worked for me.

    Another reason can be that the project is targeted at a simulator instead of a real device when building a distribution-version. That also causes this error message.

    0 讨论(0)
  • 2020-11-29 21:09

    I got the same error when setting up OCMock. I fixed it by add the libOCMock.a in 'Copy Files' section of Building Phase

    0 讨论(0)
  • 2020-11-29 21:10

    I had this error after I copy & paste a test file into the project, forgetting to change the name of the interface and implementation lines:

    @interface TDInputValidationsTests : XCTestCase
    

    and

    @implementation TDInputValidationsTests
    

    Silly mistake... I also suggest looking at the "build phases" tab on the project to check for duplicates. Deleting the derived data and making a clean-build might help as well.

    0 讨论(0)
提交回复
热议问题