Reputation: 21
I am getting the following error when trying to compile a simple program I wrote (a cipher). I understand that I have a duplicate symbol _OBJC_METACLASS_$_Cipher, but I am unsure of what is happening to cause this. I tried to check to see if I accidentally imported stuff twice, but all was good. Any help is much appreciated! :)
Ld "/Users/Lukas/Library/Developer/Xcode/DerivedData/Caesar_Shift-drfzwlpgygkbcifoefghycamkoya/Build/Products/Debug-iphonesimulator/Caesar Shift.app/Caesar Shift" normal i386
cd "/Users/Lukas/Documents/Programming/iPhone Applications/Caesar Shift"
setenv MACOSX_DEPLOYMENT_TARGET 10.6
setenv PATH "/Developer/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch i386 -isysroot /Developer/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk -L/Users/Lukas/Library/Developer/Xcode/DerivedData/Caesar_Shift-drfzwlpgygkbcifoefghycamkoya/Build/Products/Debug-iphonesimulator -F/Users/Lukas/Library/Developer/Xcode/DerivedData/Caesar_Shift-drfzwlpgygkbcifoefghycamkoya/Build/Products/Debug-iphonesimulator -filelist "/Users/Lukas/Library/Developer/Xcode/DerivedData/Caesar_Shift-drfzwlpgygkbcifoefghycamkoya/Build/Intermediates/Caesar Shift.build/Debug-iphonesimulator/Caesar Shift.build/Objects-normal/i386/Caesar Shift.LinkFileList" -mmacosx-version-min=10.6 -Xlinker -objc_abi_version -Xlinker 2 -fobjc-arc -Xlinker -no_implicit_dylibs -D__IPHONE_OS_VERSION_MIN_REQUIRED=50100 -framework UIKit -framework Foundation -framework CoreGraphics -o "/Users/Lukas/Library/Developer/Xcode/DerivedData/Caesar_Shift-drfzwlpgygkbcifoefghycamkoya/Build/Products/Debug-iphonesimulator/Caesar Shift.app/Caesar Shift"
ld: duplicate symbol _OBJC_METACLASS_$_Cipher in /Users/Lukas/Library/Developer/Xcode/DerivedData/Caesar_Shift-drfzwlpgygkbcifoefghycamkoya/Build/Intermediates/Caesar Shift.build/Debug-iphonesimulator/Caesar Shift.build/Objects-normal/i386/CaesarShiftViewController.o and /Users/Lukas/Library/Developer/Xcode/DerivedData/Caesar_Shift-drfzwlpgygkbcifoefghycamkoya/Build/Intermediates/Caesar Shift.build/Debug-iphonesimulator/Caesar Shift.build/Objects-normal/i386/CaesarShiftAppDelegate.o for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Upvotes: 1
Views: 1007
Reputation: 385600
Here are two likely reasons for this error:
You have put @implementation Cipher
in a header file (probably the Cipher.h
header file), and you've imported that header file in both CaesarShiftViewController.m
and CaesarShiftAppDelegate.m
. An @implementation
statement goes in a .m
file, not a .h
file.
You have accidentally imported Cipher.m
in both CaesarShiftViewController.m
and CaesarShiftAppDelegate.m
. You were supposed to import Cipher.h
(notice the suffix!).
As HachiEthan pointed out in a comment, you might have imported Cipher.m
in your Caeser Shift-Prefix.pch
file (in the “Supporting Files” group). This file is automatically imported by all .m
files, so it would have the same effect as my #2 above.
Upvotes: 4