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 trialTim Polehn
7,461 PointsI get an Apple Match-O Linker Error when using the NS_ENUM(int16_t, THDiaryEntryMood){...}; please advise?
I am running Xcode 6.4
5 Answers
Donald Fung
2,428 PointsI 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?
Joshua O'Connor
6,005 PointsPlaced the Enum inside ____+CoreDataProperties.m below the #import statement and it compiled fine.
Gabe Nadel
Treehouse Guest TeacherCan 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
Tim Polehn
7,461 Points// // 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
Treehouse Guest TeacherTry 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.
Gabe Nadel
Treehouse Guest TeacherGabe Nadel
Treehouse Guest TeacherThe 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?