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
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.
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;
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.
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.
I got the same error when setting up OCMock. I fixed it by add the libOCMock.a in 'Copy Files' section of Building Phase
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.