code

아키텍처 i386 clang에 대한 중복 기호

codestyles 2020. 12. 26. 10:06
반응형

아키텍처 i386 clang에 대한 중복 기호


이 오류와 관련된 Google 및 stackoverflow에서 여러 게시물을 보았습니다. 모두 읽었지만 여전히 문제를 가져오고 있습니다. 해결책에 기뻐할 것입니다. 컴파일 할 때받는 오류 메시지는 다음과 같습니다.

'-L / Users / somefolder / Documents / Bharat / MyApp copy / GoogleAdMobAdsSDK'중복 기호 _OBJC_CLASS _ $ _ AppDelegate in : / Users / madept / Library / Developer / Xcode / DerivedData / Alpha-dvvymdlmzseytagllsmbbrxdgutz / Build / Intermediates / Alpha.build/Debug-iphonesimulator/Alpha.build/Objects-normal/i386/AppDelegate-56890B6B994A4284.o

감사.


이 오류가 자주 발생하는 또 다른 이유는 실수로 .h 대신 .m 파일을 가져 오는 것입니다.


단계 :

  1. 대상 설정에서 빌드 단계를 확인하십시오.
  2. 파일이 두 번 또는 한 번 존재하는지 확인하십시오.
  3. 파일이 두 번 존재하면 하나를 삭제하십시오. 최신 파일 인 하단의 파일을 삭제하지 않을 경우.
  4. 다시 빌드하십시오.

가능한 솔루션을 추가하기 위해.

제 경우에는 헤더 파일에서 실수로 변수를 선언하고 초기화했습니다.

예를 들어 이것은 잘못되었습니다.

MyFile.h

#import <Foundation/Foundation.h>

NSInteger const ABCMyConstant = 6;

그것은해야한다:

MyFile.h

#import <Foundation/Foundation.h>

NSInteger const ABCMyConstant;

MyFile.m

#import "MyFile.h"

NSInteger const ABCMyConstant = 6;

빌드 설정으로 이동하지 않고 검색 공통 블록 하고 설정 NO . 다시 빌드하면이 오류가 다시 발생하지 않습니다.


다른 .m 파일에서 다른 const이름과 같은 이름을 가진 .m 파일에서 선언 했을 때 오류가 발생하는 것을 발견했습니다 const. 두 파일 모두 동일한 상위 파일을 # 포함했습니다.


Core Data에 대한 모델 클래스를 다시 만든 후 방금 경험했습니다. 객체 클래스를 생성하는 메뉴 옵션이 중복 모델 클래스를 생성했습니다. 복제를 제거하면 오류가 사라졌습니다 ...


링커 오류는 항상 라이브러리 사용 또는 가져 오기 문제와 관련된 문제를 표시합니다.

.h 파일 대신 .m 파일을 가져올 때 오류가 발생하는 경우가 있습니다.

코드를 확인하고 헤더 파일 (.h 확장자) 중 하나에서 .m import 문을 찾으십시오. 비슷한 문제가 발생했고 14 개의 중복 기호 오류가 발생했습니다.

ViewControler.m.h 대신 가져 왔는지 확인하십시오 .

    import "ViewController.h"

그리고 당신 AppDelegate.h은 다음과 같아야합니다.

import "UIKit/UIKit.h"
import "ViewController.h"
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (strong,nonatomic) ViewController *mainController;
@end

항상 .m이 아닌 헤더 파일을 가져 오는 것을 잊지 마십시오.


다른 사람들이 다른 모든 답변을 시도했지만 여전히 작동하지 않으면 좋아하는 텍스트 편집기로 .xcodeproj 파일을 열고 문제를 일으키는 클래스 이름을 검색해보십시오. 이 작업을 수행하기 전에 Xcode를 닫아야합니다. 파일에는 .h에 대한 한 줄과 .m에 대한 다른 줄이 있어야합니다. 중복이있는 경우 제거하고 파일을 저장 한 다음 다시 빌드하십시오.


다른 프로젝트에서 일한 것으로 알고있는 프레임 워크에이 문제가있었습니다. 다른 프로젝트의 파일을 복사하여이 프로젝트에 추가했습니다. 그런 다음 빌드 할 때 76 개의 중복 오류가 발생했습니다.

나를위한 간단한 해결책 -ObjC은 기타 링커 플래그에서 제거하는 것입니다. 이전 프로젝트에는 없었습니다. 그렇게하면 경고가 사라지고 프로젝트가 성공적으로 구축되었습니다.


라이브러리에 대한 참조가있는 두 번째 라이브러리도 포함하면서 메인 프로젝트에 정적 라이브러리가 포함되어있을 때이 오류가 발생했습니다. 그것은 꽤 혼란 스럽기 때문에 아마도 이것은 더 명확 할 것입니다.

MyWorkspace + 메인 프로젝트 + 라이브러리 1 참조 + 라이브러리 2 참조 + 라이브러리 1 + 라이브러리 2 + 라이브러리 1 참조

메인 프로젝트에서 라이브러리 1에 대한 참조를 제거하고 오류가 사라졌습니다.


또 다른 이유는 배포 버전을 구축 할 때 프로젝트가 실제 장치가 아닌 시뮬레이터를 대상으로하기 때문일 수 있습니다. 또한이 오류 메시지가 발생합니다.


마침내 해결책을 얻었습니다.

  1. 내가 추가 한 AdMob SDK의 모든 참조를 제거합니다 (작업 영역에서도 삭제).
  2. 프로젝트 정리
  3. AdMob을 다시 추가하려면이 링크를 클릭하세요.
  4. 청소 및 재건

이 문제를 해결하는 가장 쉬운 방법은 문제 Xcode 7.0 또는 후자는 No Common Blocks를 NO로 변경하면 문제가 해결됩니다.이 Project Target> Build Setting> No Common Blocks를 시도해보세요. NO로 변경합니다.


어떤 경우에는 두 개의 다른 파일에서 동일한 이름을 가진 상수 (const)를 실수로 선언했기 때문에 "건축용 중복 기호 ..."오류가 발생할 수도 있습니다.


동일한 C 함수를 두 번 정의한 곳에서 사용했습니다. 두 개의 다른 .m파일에서. 정의와 짜잔 중 하나를 제거하기 만하면됩니다.


프로젝트 정리를 시도하고 모든 파생 데이터를 지 웠습니다. 작동하지 않았습니다. Atlas, 이것은 나를 위해 일했습니다.

enter image description here

또 다른 이유는 배포 버전을 구축 할 때 프로젝트가 실제 장치가 아닌 시뮬레이터를 대상으로하기 때문일 수 있습니다. 또한이 오류 메시지가 발생합니다.


It was different for me, I copied over the class implementation methods as is and the iVars were also copied over... so in the world of iVars there are two sets and the compiler kept complaining about duplicate ivars before linking the *.o files.

reading the output helped so removed all the duplicating ivars... thanks to the new feature where you need not @synthesize all your properties... the error went away...


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.


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.


Sometimes believe it or not, Xcode screws up the project file. The only solution we found was to manually remove every reference to the offending file using a text editor, then re-add the files in Xcode.


Note to self: "READ THE ERROR!"

In my case it says this: duplicate symbol _OBJC_CLASS_$_SATCoreData in:

Translation: an Objective C Class called SATCoreData is duplicated.

Then it gives the path to both occurrences of the symbol. Reading the path points to the two the class file ending in .o. If you look at both classes you will find something fishy. In my case I had accidently given two classes the same name. One class I had inside the file of another class because I was testing something and was too lazy to make a separate class. Hope this helps someone.


I had that problem and I was stuck for a while. The thing for me that caused the problem was I wrote some boolean into .h file (between #import and @interface) and use them into my .m file

I simply deleted them from my .h file and and copied them into the same place into my .m file and the build succeed.


Taken from https://stackoverflow.com/a/2755581/190599

What you can do is put in your header (MyConstants.h):

extern const int MyConstant;
extern NSString * const MyStringConstant;

And in a source file, include the header above but define the constants (MyConstants.m):

const int MyConstant = 123;
NSString * const MyStringConstant = @"SomeString";

Then, you simply need to include the header in any other source file that uses either of these constants. The header is simply declaring that these constants exist somewhere, so the compiler won't complain, because it's the linker's job to resolve these constant names. The source file that contains your constant definitions gets compiled, and the linker sees that this is where the constants are, and resolves all of the references found in the other source files.

The problem with declaring and defining a constant in a header (that is not declared as static) is that the compiler treats it as an independent global for each file that includes that header. When the linker tries to link all of your compiled sources together it encounters the global name as many times as you have included MyConstants.h.

ReferenceURL : https://stackoverflow.com/questions/12279622/duplicate-symbols-for-architecture-i386-clang

반응형