重复的符号在Xcode架构(duplicate symbols for architectures

2019-07-01 11:50发布

以下是编译时我收到错误消息...

Ld /Users/ilia3546/Library/Developer/Xcode/DerivedData/MasterDetail-fhgogwnbpzovbtaskgecptdnvgjs/Build/Products/Debug-iphonesimulator/MasterDetail.app/MasterDetail normal i386
    cd /Users/ilia3546/Проекты/iDecide
    setenv IPHONEOS_DEPLOYMENT_TARGET 5.0
    setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.0.sdk -L/Users/ilia3546/Library/Developer/Xcode/DerivedData/MasterDetail-fhgogwnbpzovbtaskgecptdnvgjs/Build/Products/Debug-iphonesimulator -F/Users/ilia3546/Library/Developer/Xcode/DerivedData/MasterDetail-fhgogwnbpzovbtaskgecptdnvgjs/Build/Products/Debug-iphonesimulator -filelist /Users/ilia3546/Library/Developer/Xcode/DerivedData/MasterDetail-fhgogwnbpzovbtaskgecptdnvgjs/Build/Intermediates/MasterDetail.build/Debug-iphonesimulator/MasterDetail.build/Objects-normal/i386/MasterDetail.LinkFileList -Xlinker -objc_abi_version -Xlinker 2 -fobjc-link-runtime -Xlinker -no_implicit_dylibs -mios-simulator-version-min=5.0 -framework UIKit -framework Foundation -framework CoreGraphics -o /Users/ilia3546/Library/Developer/Xcode/DerivedData/MasterDetail-fhgogwnbpzovbtaskgecptdnvgjs/Build/Products/Debug-iphonesimulator/MasterDetail.app/MasterDetail

duplicate symbol _main in:
    /Users/ilia3546/Library/Developer/Xcode/DerivedData/MasterDetail-fhgogwnbpzovbtaskgecptdnvgjs/Build/Intermediates/MasterDetail.build/Debug-iphonesimulator/MasterDetail.build/Objects-normal/i386/main-E0BAF2CA88EDEE32.o
duplicate symbol _OBJC_IVAR_$_MasterDetailAppDelegate._window in:
    /Users/ilia3546/Library/Developer/Xcode/DerivedData/MasterDetail-fhgogwnbpzovbtaskgecptdnvgjs/Build/Intermediates/MasterDetail.build/Debug-iphonesimulator/MasterDetail.build/Objects-normal/i386/MasterDetailAppDelegate-C2C06F734ECE2E36.o
duplicate symbol _OBJC_IVAR_$_MasterDetailAppDelegate._navigationController in:
    /Users/ilia3546/Library/Developer/Xcode/DerivedData/MasterDetail-fhgogwnbpzovbtaskgecptdnvgjs/Build/Intermediates/MasterDetail.build/Debug-iphonesimulator/MasterDetail.build/Objects-normal/i386/MasterDetailAppDelegate-C2C06F734ECE2E36.o
duplicate symbol _OBJC_IVAR_$_MasterDetailAppDelegate._splitViewController in:
    /Users/ilia3546/Library/Developer/Xcode/DerivedData/MasterDetail-fhgogwnbpzovbtaskgecptdnvgjs/Build/Intermediates/MasterDetail.build/Debug-iphonesimulator/MasterDetail.build/Objects-normal/i386/MasterDetailAppDelegate-C2C06F734ECE2E36.o
duplicate symbol _OBJC_CLASS_$_MasterDetailAppDelegate in:
    /Users/ilia3546/Library/Developer/Xcode/DerivedData/MasterDetail-fhgogwnbpzovbtaskgecptdnvgjs/Build/Intermediates/MasterDetail.build/Debug-iphonesimulator/MasterDetail.build/Objects-normal/i386/MasterDetailAppDelegate-C2C06F734ECE2E36.o
duplicate symbol _OBJC_METACLASS_$_MasterDetailAppDelegate in:
    /Users/ilia3546/Library/Developer/Xcode/DerivedData/MasterDetail-fhgogwnbpzovbtaskgecptdnvgjs/Build/Intermediates/MasterDetail.build/Debug-iphonesimulator/MasterDetail.build/Objects-normal/i386/MasterDetailAppDelegate-C2C06F734ECE2E36.o
duplicate symbol _OBJC_IVAR_$_MasterDetailDetailViewController._detailItem in:
    /Users/ilia3546/Library/Developer/Xcode/DerivedData/MasterDetail-fhgogwnbpzovbtaskgecptdnvgjs/Build/Intermediates/MasterDetail.build/Debug-iphonesimulator/MasterDetail.build/Objects-normal/i386/MasterDetailDetailViewController-B3C32DC7B1BE4E38.o
duplicate symbol _OBJC_IVAR_$_MasterDetailDetailViewController._TitleOfDetail in:
    /Users/ilia3546/Library/Developer/Xcode/DerivedData/MasterDetail-fhgogwnbpzovbtaskgecptdnvgjs/Build/Intermediates/MasterDetail.build/Debug-iphonesimulator/MasterDetail.build/Objects-normal/i386/MasterDetailDetailViewController-B3C32DC7B1BE4E38.o
duplicate symbol _OBJC_IVAR_$_MasterDetailDetailViewController._detailDescriptionLabel in:
    /Users/ilia3546/Library/Developer/Xcode/DerivedData/MasterDetail-fhgogwnbpzovbtaskgecptdnvgjs/Build/Intermediates/MasterDetail.build/Debug-iphonesimulator/MasterDetail.build/Objects-normal/i386/MasterDetailDetailViewController-B3C32DC7B1BE4E38.o
duplicate symbol _OBJC_IVAR_$_MasterDetailDetailViewController._masterPopoverController in:
    /Users/ilia3546/Library/Developer/Xcode/DerivedData/MasterDetail-fhgogwnbpzovbtaskgecptdnvgjs/Build/Intermediates/MasterDetail.build/Debug-iphonesimulator/MasterDetail.build/Objects-normal/i386/MasterDetailDetailViewController-B3C32DC7B1BE4E38.o
duplicate symbol _OBJC_IVAR_$_MasterDetailDetailViewController.WebView in:
    /Users/ilia3546/Library/Developer/Xcode/DerivedData/MasterDetail-fhgogwnbpzovbtaskgecptdnvgjs/Build/Intermediates/MasterDetail.build/Debug-iphonesimulator/MasterDetail.build/Objects-normal/i386/MasterDetailDetailViewController-B3C32DC7B1BE4E38.o
duplicate symbol _OBJC_CLASS_$_MasterDetailDetailViewController in:
    /Users/ilia3546/Library/Developer/Xcode/DerivedData/MasterDetail-fhgogwnbpzovbtaskgecptdnvgjs/Build/Intermediates/MasterDetail.build/Debug-iphonesimulator/MasterDetail.build/Objects-normal/i386/MasterDetailDetailViewController-B3C32DC7B1BE4E38.o
duplicate symbol _OBJC_METACLASS_$_MasterDetailDetailViewController in:
    /Users/ilia3546/Library/Developer/Xcode/DerivedData/MasterDetail-fhgogwnbpzovbtaskgecptdnvgjs/Build/Intermediates/MasterDetail.build/Debug-iphonesimulator/MasterDetail.build/Objects-normal/i386/MasterDetailDetailViewController-B3C32DC7B1BE4E38.o
duplicate symbol _OBJC_IVAR_$_MasterDetailMasterViewController._detailViewController in:
    /Users/ilia3546/Library/Developer/Xcode/DerivedData/MasterDetail-fhgogwnbpzovbtaskgecptdnvgjs/Build/Intermediates/MasterDetail.build/Debug-iphonesimulator/MasterDetail.build/Objects-normal/i386/MasterDetailMasterViewController-A4C5EC1C14AE6E3A.o
duplicate symbol _OBJC_IVAR_$_MasterDetailMasterViewController._Controller1 in:
    /Users/ilia3546/Library/Developer/Xcode/DerivedData/MasterDetail-fhgogwnbpzovbtaskgecptdnvgjs/Build/Intermediates/MasterDetail.build/Debug-iphonesimulator/MasterDetail.build/Objects-normal/i386/MasterDetailMasterViewController-A4C5EC1C14AE6E3A.o
duplicate symbol _OBJC_IVAR_$_MasterDetailMasterViewController.listOfDecide in:
    /Users/ilia3546/Library/Developer/Xcode/DerivedData/MasterDetail-fhgogwnbpzovbtaskgecptdnvgjs/Build/Intermediates/MasterDetail.build/Debug-iphonesimulator/MasterDetail.build/Objects-normal/i386/MasterDetailMasterViewController-A4C5EC1C14AE6E3A.o
duplicate symbol _OBJC_IVAR_$_MasterDetailMasterViewController.listOfDecideOpis in:
    /Users/ilia3546/Library/Developer/Xcode/DerivedData/MasterDetail-fhgogwnbpzovbtaskgecptdnvgjs/Build/Intermediates/MasterDetail.build/Debug-iphonesimulator/MasterDetail.build/Objects-normal/i386/MasterDetailMasterViewController-A4C5EC1C14AE6E3A.o
duplicate symbol _OBJC_IVAR_$_MasterDetailMasterViewController.listOfGraph in:
    /Users/ilia3546/Library/Developer/Xcode/DerivedData/MasterDetail-fhgogwnbpzovbtaskgecptdnvgjs/Build/Intermediates/MasterDetail.build/Debug-iphonesimulator/MasterDetail.build/Objects-normal/i386/MasterDetailMasterViewController-A4C5EC1C14AE6E3A.o
duplicate symbol _OBJC_IVAR_$_MasterDetailMasterViewController.listOfGraphOpis in:
    /Users/ilia3546/Library/Developer/Xcode/DerivedData/MasterDetail-fhgogwnbpzovbtaskgecptdnvgjs/Build/Intermediates/MasterDetail.build/Debug-iphonesimulator/MasterDetail.build/Objects-normal/i386/MasterDetailMasterViewController-A4C5EC1C14AE6E3A.o
duplicate symbol _OBJC_IVAR_$_MasterDetailMasterViewController.listOfAbout in:
    /Users/ilia3546/Library/Developer/Xcode/DerivedData/MasterDetail-fhgogwnbpzovbtaskgecptdnvgjs/Build/Intermediates/MasterDetail.build/Debug-iphonesimulator/MasterDetail.build/Objects-normal/i386/MasterDetailMasterViewController-A4C5EC1C14AE6E3A.o
duplicate symbol _OBJC_IVAR_$_MasterDetailMasterViewController.listOfAboutOpis in:
    /Users/ilia3546/Library/Developer/Xcode/DerivedData/MasterDetail-fhgogwnbpzovbtaskgecptdnvgjs/Build/Intermediates/MasterDetail.build/Debug-iphonesimulator/MasterDetail.build/Objects-normal/i386/MasterDetailMasterViewController-A4C5EC1C14AE6E3A.o
duplicate symbol _OBJC_CLASS_$_MasterDetailMasterViewController in:
    /Users/ilia3546/Library/Developer/Xcode/DerivedData/MasterDetail-fhgogwnbpzovbtaskgecptdnvgjs/Build/Intermediates/MasterDetail.build/Debug-iphonesimulator/MasterDetail.build/Objects-normal/i386/MasterDetailMasterViewController-A4C5EC1C14AE6E3A.o
duplicate symbol _OBJC_METACLASS_$_MasterDetailMasterViewController in:
    /Users/ilia3546/Library/Developer/Xcode/DerivedData/MasterDetail-fhgogwnbpzovbtaskgecptdnvgjs/Build/Intermediates/MasterDetail.build/Debug-iphonesimulator/MasterDetail.build/Objects-normal/i386/MasterDetailMasterViewController-A4C5EC1C14AE6E3A.o
ld: 23 duplicate symbols for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

appdelegate.m -

#import "MasterDetailAppDelegate.h"

#import "MasterDetailMasterViewController.h"

#import "MasterDetailDetailViewController.h"


@implementation MasterDetailAppDelegate

@synthesize window = _window;
@synthesize navigationController = _navigationController;
@synthesize splitViewController = _splitViewController;

- (void)dealloc
{
    [_window release];
    [_navigationController release];
    [_splitViewController release];
    [super dealloc];
}


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
    // Override point for customization after application launch.
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
            MasterDetailMasterViewController *masterViewController = [[[MasterDetailMasterViewController alloc] initWithNibName:@"MasterDetailMasterViewController_iPhone" bundle:nil] autorelease];
            self.navigationController = [[[UINavigationController alloc] initWithRootViewController:masterViewController] autorelease];
            self.window.rootViewController = self.navigationController; 
    } else {
        MasterDetailMasterViewController *masterViewController = [[[MasterDetailMasterViewController alloc] initWithNibName:@"MasterDetailMasterViewController_iPad" bundle:nil] autorelease];
        UINavigationController *masterNavigationController = [[[UINavigationController alloc] initWithRootViewController:masterViewController] autorelease];

        MasterDetailDetailViewController *detailViewController = [[[MasterDetailDetailViewController alloc] initWithNibName:@"MasterDetailDetailViewController_iPad" bundle:nil] autorelease];
        UINavigationController *detailNavigationController = [[[UINavigationController alloc] initWithRootViewController:detailViewController] autorelease];
        self.splitViewController = [[[UISplitViewController alloc] init] autorelease];
        self.splitViewController.delegate = detailViewController;
        self.splitViewController.viewControllers = [NSArray arrayWithObjects:masterNavigationController, detailNavigationController, nil];

        self.window.rootViewController = self.splitViewController;
    }
    [self.window makeKeyAndVisible];
    return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application
{
    /*
     Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
     Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
     */
}

- (void)applicationDidEnterBackground:(UIApplication *)application
{
    /*
     Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 
     If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
     */
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
    /*
     Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
     */
}

- (void)applicationDidBecomeActive:(UIApplication *)application
{
    /*
     Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
     */
}

- (void)applicationWillTerminate:(UIApplication *)application
{
    /*
     Called when the application is about to terminate.
     Save data if appropriate.
     See also applicationDidEnterBackground:.
     */
}

@end

main.m文件 -

//
//  main.m
//  MasterDetail
//
//  Created by Wei-Meng Lee on 3/9/11.
//  Copyright (c) 2011 __MyCompanyName__. All rights reserved.
//

#import <UIKit/UIKit.h>

#import "MasterDetailAppDelegate.h"

int main(int argc, char *argv[])
{
    @autoreleasepool {
        return UIApplicationMain(argc, argv, nil, NSStringFromClass([MasterDetailAppDelegate class]));
    }
}

我检查导入.m文件,而不是.H,但都正确。

Answer 1:

在你的构建阶段,请检查你是不是编译相同的文件超过一次。 也就是说,如果你搜索的main.m它应该只返回一个结果。

如果这不是问题,可以从您的main.m的问题添加的代码?



Answer 2:

检查您的导入文件,它可能是你导入.m文件。

#import "TimeModel.m"


Answer 3:

虽然下面是不是在OP的情况的原因,它是我的,所以我会在这里分享的人面临着同样的错误:

如果你在所有的全局变量得到一个链接错误,你可能需要添加extern在头文件到他们的声明。

无论缺少的extern会产生这个问题的是依赖于构建设置,更具体地说上的“苹果LLVM - 代码生成”,“无公共块”(GCC_NO_COMMON_BLOCKS,-fno-常见)。 如果设置为yes,这是在Xcode的较新版本的默认,你会得到一个链接错误,而不extern

为什么EXTERN?

extern关键字使得它的声明只(即不还的定义),它因为它是一个头文件是你想要的。 一些编译器允许其不进行extern和依然是“做正确的事”,但省略的extern气馁。 这就是为什么在默认情况下的Xcode的较新版本启用警告。



Answer 4:

这是在Xcode 7.0的情况下重复的符号错误,以防其他人遇到这种情况

.h file

NSUserDefaults *defaults; // <----placing this above the @interface caused the issue

@interface someViewController

//...

改成

.h file

@interface someViewController

{
   NSUserDefaults *defaults;
}

//...


Answer 5:

当你在不同的实现不同文件相同的@interface这也发生。 例如你有一个Player类,在Player.h / M档,你有一个匹配类(Match.h / M)和比赛是两个播放之间,而不是前述的球员。

Player.h

@interface Player : NSObject
@property (nonatomic) NSUInteger _id;
@property (nonatomic, strong) NSString* firstName;
@property (nonatomic, strong) NSString* lastName;
@property (nonatomic, strong) NSString* username;
@end

Match.h

@class Player

@interface Match : NSObject
@property (nonatomic, strong) Player* player1;
@property (nonatomic, strong) Player* player2;
@property (nonatomic) NSUInteger matchId;
@end

@interface Player : NSObject
@property (nonatomic, strong) NSString* nickName;
@property (nonatomic, strong) NSString* point;
@property (nonatomic, strong) NSNumber* lastMove;
@end

在这种情况下,编译器看到两个不同的播放器类的实现。 您需要重构在Match.h文件MatchPlayer Player类。



Answer 6:

在我的情况的问题是,.m文件被列入两次。

问题:

原因:

解决方案:只保留一个文件引用。



Answer 7:

我跑进其中一个问题typedef没有添加到一个enum和2个文件之间出现重复的符号错误。

enum <name> {
 ...
} <name>;

通过增加typedefenum固定重复的符号。



Answer 8:

如果帮助别人,这是我的情况:

我想在1头和实现文件中声明2个小班。

类2是使用第1类

当我得到的错误,这是这种情况:
头文件 - 接口+实施1类,2类的接口
实现文件 - 执行2班

之后我搬到1类的实现从头文件来实现文件,没有错误和问题的解决:
头文件 - 1类的接口,2类的接口
实现文件 - 执行1班,实行2班



Answer 9:

就我而言,我有相同的实体名称和NSManagedObject名字,并没有设置实体代码生成类为“手动/无”的数据模型督察。



文章来源: duplicate symbols for architectures in Xcode