1

I'm currently learning how to use Objective-C And I was doing a simple project involving classes I decided to plop it into Xcode for some easy visual debugging but upon ironing out all the errors and warnings I ran into that:

duplicate symbol _OBJC_IVAR_$_Customer._fName in:
/Users/Slench/Library/Developer/Xcode/DerivedData/NameRankIntention-hlaqvlslfjimqdeysxqiyloirdus/Build/Intermediates/NameRankIntention.build/Debug/NameRankIntention.build/Objects-normal/x86_64/main.o
/Users/Slench/Library/Developer/Xcode/DerivedData/NameRankIntention-hlaqvlslfjimqdeysxqiyloirdus/Build/Intermediates/NameRankIntention.build/Debug/NameRankIntention.build/Objects-normal/x86_64/NRaI.o
duplicate symbol _OBJC_IVAR_$_Customer._lName in:
/Users/Slench/Library/Developer/Xcode/DerivedData/NameRankIntention-hlaqvlslfjimqdeysxqiyloirdus/Build/Intermediates/NameRankIntention.build/Debug/NameRankIntention.build/Objects-normal/x86_64/main.o
/Users/Slench/Library/Developer/Xcode/DerivedData/NameRankIntention-hlaqvlslfjimqdeysxqiyloirdus/Build/Intermediates/NameRankIntention.build/Debug/NameRankIntention.build/Objects-normal/x86_64/NRaI.o
duplicate symbol _OBJC_IVAR_$_Customer._age in:
/Users/Slench/Library/Developer/Xcode/DerivedData/NameRankIntention-hlaqvlslfjimqdeysxqiyloirdus/Build/Intermediates/NameRankIntention.build/Debug/NameRankIntention.build/Objects-normal/x86_64/main.o
/Users/Slench/Library/Developer/Xcode/DerivedData/NameRankIntention-hlaqvlslfjimqdeysxqiyloirdus/Build/Intermediates/NameRankIntention.build/Debug/NameRankIntention.build/Objects-normal/x86_64/NRaI.o
duplicate symbol _OBJC_IVAR_$_Customer._rank in:
/Users/Slench/Library/Developer/Xcode/DerivedData/NameRankIntention-hlaqvlslfjimqdeysxqiyloirdus/Build/Intermediates/NameRankIntention.build/Debug/NameRankIntention.build/Objects-normal/x86_64/main.o
/Users/Slench/Library/Developer/Xcode/DerivedData/NameRankIntention-hlaqvlslfjimqdeysxqiyloirdus/Build/Intermediates/NameRankIntention.build/Debug/NameRankIntention.build/Objects-normal/x86_64/NRaI.o
duplicate symbol _OBJC_IVAR_$_Customer._intention in:
/Users/Slench/Library/Developer/Xcode/DerivedData/NameRankIntention-hlaqvlslfjimqdeysxqiyloirdus/Build/Intermediates/NameRankIntention.build/Debug/NameRankIntention.build/Objects-normal/x86_64/main.o
/Users/Slench/Library/Developer/Xcode/DerivedData/NameRankIntention-hlaqvlslfjimqdeysxqiyloirdus/Build/Intermediates/NameRankIntention.build/Debug/NameRankIntention.build/Objects-normal/x86_64/NRaI.o
duplicate symbol _OBJC_METACLASS_$_Customer in:
/Users/Slench/Library/Developer/Xcode/DerivedData/NameRankIntention-hlaqvlslfjimqdeysxqiyloirdus/Build/Intermediates/NameRankIntention.build/Debug/NameRankIntention.build/Objects-normal/x86_64/main.o
/Users/Slench/Library/Developer/Xcode/DerivedData/NameRankIntention-hlaqvlslfjimqdeysxqiyloirdus/Build/Intermediates/NameRankIntention.build/Debug/NameRankIntention.build/Objects-normal/x86_64/NRaI.o
duplicate symbol _OBJC_CLASS_$_Customer in:
/Users/Slench/Library/Developer/Xcode/DerivedData/NameRankIntention-hlaqvlslfjimqdeysxqiyloirdus/Build/Intermediates/NameRankIntention.build/Debug/NameRankIntention.build/Objects-normal/x86_64/main.o
/Users/Slench/Library/Developer/Xcode/DerivedData/NameRankIntention-hlaqvlslfjimqdeysxqiyloirdus/Build/Intermediates/NameRankIntention.build/Debug/NameRankIntention.build/Objects-normal/x86_64/NRaI.o
ld: 7 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Now the weird thing is that I then put the "fixed code" back into Sublime Text, where I saved it and then compiled it through the terminal where it worked just fine no errors no warnings nothing

I've read through some of the other questions regarding this and the solution has either always been that they have found the duplicate declaration, or that they had an extra file by the same name that resulted in duplicate declarations... I have neither...

so... any help?

1 Answer 1

1

Are you possibly importing the 'NRaI.m' file in main.m by accident?

3
  • why would that be bad? doing so makes it work outside of xcode Aug 8, 2012 at 22:00
  • can you please shed some light on why is that an issue? Or could you point to any documentation which does that .. Nov 21, 2012 at 21:26
  • 1
    @manishKungwani XCode has the .m file scheduled for building into the target as an independent object module. Including another module is legal since it is merely a preprocessor directive. ObjC and any C-based language will compile main.X without any issue at all. However, when you go to link the final build, the linker will choke finding exact duplicates of the symbols in two object modules. So, the correct was to include the interface file to get the declaration of the implementation and let the other .m compile into its own obj module so we can link it later to resolve the symbols.
    – dans3itz
    Nov 23, 2012 at 1:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.