2012-07-30 68 views
1

嘗試編譯我編寫的簡單程序(密碼)時出現以下錯誤。我知道我有一個重複的符號_OBJC_METACLASS _ $ _ Cipher,但我不確定導致這種情況的原因。我試圖檢查是否意外地輸入了兩次東西,但都很好。任何幫助深表感謝! :)Objective-C和Xcode中的重複符號錯誤

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) 
+2

任何相關的代碼?鏈接器中提到的兩個文件以及類最初聲明的頭文件將有所幫助 – 2012-07-30 18:23:31

+1

鏈接器不會說謊! =)您已經在CaesarShiftViewController或CaesarShiftAppDelegate中重新聲明或導入了'Cipher'。仔細檢查你的'.pch'文件。 – MechEthan 2012-07-30 18:28:01

回答

4

下面是此錯誤的兩種可能的原因:

  1. 您已經在頭文件(可能是Cipher.h頭文件)把@implementation Cipher,並已導入該頭文件均爲CaesarShiftViewController.mCaesarShiftAppDelegate.m@implementation聲明在.m文件中,而不是在.h文件中。

  2. 您在CaesarShiftViewController.mCaesarShiftAppDelegate.m中均意外導入了Cipher.m。你應該輸入Cipher.h(注意後綴!)。

由於HachiEthan在評論中指出,你可能在你的Caeser Shift-Prefix.pch文件導入Cipher.m(以下簡稱「配套文件」組)。這個文件被所有的.m文件自動導入,所以它會和上面的#2有相同的效果。