Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Build a Diary App Using Core Data Understanding Core Data Defining our Data Model

I get an Apple Match-O Linker Error when using the NS_ENUM(int16_t, THDiaryEntryMood){...}; please advise?

I am running Xcode 6.4

Gabe Nadel
seal-mask
.a{fill-rule:evenodd;}techdegree
Gabe Nadel
Treehouse Guest Teacher

The community will be happy to help, but I think we need a bit more info. Can you share the entire file where that code snippet is found, along with the file where that enum is defined? I addition, can you share the entire text of the Linker Error?

5 Answers

I am actually experiencing a similar problem at the moment. This is the error I am getting:

duplicate symbol _THDiaryEntryMood in: /Users/blaynechong/Library/Developer/Xcode/DerivedData/5-Diary-fefwxjwtipxgpohievpqmqmplivu/Build/Intermediates/5-Diary.build/Debug-iphonesimulator/5-Diary.build/Objects-normal/x86_64/THNewEntryViewController.o /Users/blaynechong/Library/Developer/Xcode/DerivedData/5-Diary-fefwxjwtipxgpohievpqmqmplivu/Build/Intermediates/5-Diary.build/Debug-iphonesimulator/5-Diary.build/Objects-normal/x86_64/THDiaryEntry.o ld: 1 duplicate symbol for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

So it points to the block of code that we wrote previously in the THDiaryEntry.h file.

NS_ENUM(int16_t, THDiaryEntryMood) {
    THDiaryEntryMoodGood = 0,
    THDiaryEntryMoodAverage = 1,
    THDiaryEntryMoodBad = 2
};

When i comment out this code my program runs, but I would love to have a permanent solution for this problem. Can somebody help please?

Placed the Enum inside ____+CoreDataProperties.m below the #import statement and it compiled fine.

Gabe Nadel
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Gabe Nadel
Treehouse Guest Teacher

Can you post the full code for the .m and the .h files?

Also, two other things to check:

If you search your project, are there other places you declare: THDiaryEntryMood and/or THDiaryEntry

and

If you look in your project navigator, are there two copies of either of the files containing THDiaryEntry

// // THDiaryEntry.h // diary // // Created by Tim Polehn on 8/13/15. // Copyright (c) 2015 TimothyPolehn. All rights reserved. //

import <Foundation/Foundation.h>

import <CoreData/CoreData.h>

NS_ENUM(int16_t, THDiaryEntryMood){ THDiaryEntryMoodGood = 0, THDiaryEntryMoodAverage = 1, THDiaryEntryMoodBad = 2 };

@interface THDiaryEntry : NSManagedObject

@property (nonatomic, retain) NSString * body; @property (nonatomic) NSTimeInterval date; @property (nonatomic, retain) NSData * imageData; @property (nonatomic, retain) NSString * location; @property (nonatomic) int16_t mood;

@end

// // THDiaryEntry.m // diary // // Created by Tim Polehn on 8/13/15. // Copyright (c) 2015 TimothyPolehn. All rights reserved. //

import "THDiaryEntry.h"

@implementation THDiaryEntry

@dynamic body; @dynamic date; @dynamic imageData; @dynamic location; @dynamic mood;

@end

Gabe Nadel
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Gabe Nadel
Treehouse Guest Teacher

Try declaring your enum like this:

enum THDiaryEntryMood{THDiaryEntryMoodGood = 0, THDiaryEntryMoodAverage = 1, THDiaryEntryMoodBad = 2};

Also, where else in your PROJECT do any of the "THDiaryEntryMood" values above get used? Do a search of your project and please post that code too.