Apple Mach-O 链接器错误,目标 C
Posted
技术标签:
【中文标题】Apple Mach-O 链接器错误,目标 C【英文标题】:Apple Mach-O Linker Error, Objective C 【发布时间】:2013-10-01 08:41:34 【问题描述】:我正在尝试编译我的应用程序,但它总是出现此错误“Apple Mac-O Linker Error linker command failed with exit code 1 (use -v to see invocation)”这是错误代码:
Ld /Users/Sarthak/Library/Developer/Xcode/DerivedData/Tap!-gtxtrvaffmxxtocfqejemafixgvx/Build/Products/Debug-iphonesimulator/Tap!.app/Tap! normal i386
cd "/Users/Sarthak/Documents/Programming/ios and Mac OSX Programming/iOS/Tap!"
setenv IPHONEOS_DEPLOYMENT_TARGET 7.0
setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk -L/Users/Sarthak/Library/Developer/Xcode/DerivedData/Tap!-gtxtrvaffmxxtocfqejemafixgvx/Build/Products/Debug-iphonesimulator -F/Users/Sarthak/Library/Developer/Xcode/DerivedData/Tap!-gtxtrvaffmxxtocfqejemafixgvx/Build/Products/Debug-iphonesimulator -filelist /Users/Sarthak/Library/Developer/Xcode/DerivedData/Tap!-gtxtrvaffmxxtocfqejemafixgvx/Build/Intermediates/Tap!.build/Debug-iphonesimulator/Tap!.build/Objects-normal/i386/Tap!.LinkFileList -Xlinker -objc_abi_version -Xlinker 2 -fobjc-arc -fobjc-link-runtime -Xlinker -no_implicit_dylibs -mios-simulator-version-min=7.0 -framework CoreGraphics -framework UIKit -framework Foundation -Xlinker -dependency_info -Xlinker /Users/Sarthak/Library/Developer/Xcode/DerivedData/Tap!-gtxtrvaffmxxtocfqejemafixgvx/Build/Intermediates/Tap!.build/Debug-iphonesimulator/Tap!.build/Objects-normal/i386/Tap!_dependency_info.dat -o /Users/Sarthak/Library/Developer/Xcode/DerivedData/Tap!-gtxtrvaffmxxtocfqejemafixgvx/Build/Products/Debug-iphonesimulator/Tap!.app/Tap!
duplicate symbol _OBJC_IVAR_$_tapScoreController.score in:
/Users/Sarthak/Library/Developer/Xcode/DerivedData/Tap!-gtxtrvaffmxxtocfqejemafixgvx/Build/Intermediates/Tap!.build/Debug-iphonesimulator/Tap!.build/Objects-normal/i386/tapScoreController.o
/Users/Sarthak/Library/Developer/Xcode/DerivedData/Tap!-gtxtrvaffmxxtocfqejemafixgvx/Build/Intermediates/Tap!.build/Debug-iphonesimulator/Tap!.build/Objects-normal/i386/tapViewController.o
duplicate symbol _OBJC_IVAR_$_tapScoreController.gameStart in:
/Users/Sarthak/Library/Developer/Xcode/DerivedData/Tap!-gtxtrvaffmxxtocfqejemafixgvx/Build/Intermediates/Tap!.build/Debug-iphonesimulator/Tap!.build/Objects-normal/i386/tapScoreController.o
/Users/Sarthak/Library/Developer/Xcode/DerivedData/Tap!-gtxtrvaffmxxtocfqejemafixgvx/Build/Intermediates/Tap!.build/Debug-iphonesimulator/Tap!.build/Objects-normal/i386/tapViewController.o
duplicate symbol _OBJC_METACLASS_$_tapScoreController in:
/Users/Sarthak/Library/Developer/Xcode/DerivedData/Tap!-gtxtrvaffmxxtocfqejemafixgvx/Build/Intermediates/Tap!.build/Debug-iphonesimulator/Tap!.build/Objects-normal/i386/tapScoreController.o
/Users/Sarthak/Library/Developer/Xcode/DerivedData/Tap!-gtxtrvaffmxxtocfqejemafixgvx/Build/Intermediates/Tap!.build/Debug-iphonesimulator/Tap!.build/Objects-normal/i386/tapViewController.o
duplicate symbol _OBJC_CLASS_$_tapScoreController in:
/Users/Sarthak/Library/Developer/Xcode/DerivedData/Tap!-gtxtrvaffmxxtocfqejemafixgvx/Build/Intermediates/Tap!.build/Debug-iphonesimulator/Tap!.build/Objects-normal/i386/tapScoreController.o
/Users/Sarthak/Library/Developer/Xcode/DerivedData/Tap!-gtxtrvaffmxxtocfqejemafixgvx/Build/Intermediates/Tap!.build/Debug-iphonesimulator/Tap!.build/Objects-normal/i386/tapViewController.o
duplicate symbol _OBJC_IVAR_$_tapScoreController.score in:
/Users/Sarthak/Library/Developer/Xcode/DerivedData/Tap!-gtxtrvaffmxxtocfqejemafixgvx/Build/Intermediates/Tap!.build/Debug-iphonesimulator/Tap!.build/Objects-normal/i386/tapScoreController.o
/Users/Sarthak/Library/Developer/Xcode/DerivedData/Tap!-gtxtrvaffmxxtocfqejemafixgvx/Build/Intermediates/Tap!.build/Debug-iphonesimulator/Tap!.build/Objects-normal/i386/main.o
duplicate symbol _OBJC_IVAR_$_tapScoreController.gameStart in:
/Users/Sarthak/Library/Developer/Xcode/DerivedData/Tap!-gtxtrvaffmxxtocfqejemafixgvx/Build/Intermediates/Tap!.build/Debug-iphonesimulator/Tap!.build/Objects-normal/i386/tapScoreController.o
/Users/Sarthak/Library/Developer/Xcode/DerivedData/Tap!-gtxtrvaffmxxtocfqejemafixgvx/Build/Intermediates/Tap!.build/Debug-iphonesimulator/Tap!.build/Objects-normal/i386/main.o
duplicate symbol _OBJC_METACLASS_$_tapScoreController in:
/Users/Sarthak/Library/Developer/Xcode/DerivedData/Tap!-gtxtrvaffmxxtocfqejemafixgvx/Build/Intermediates/Tap!.build/Debug-iphonesimulator/Tap!.build/Objects-normal/i386/tapScoreController.o
/Users/Sarthak/Library/Developer/Xcode/DerivedData/Tap!-gtxtrvaffmxxtocfqejemafixgvx/Build/Intermediates/Tap!.build/Debug-iphonesimulator/Tap!.build/Objects-normal/i386/main.o
duplicate symbol _OBJC_CLASS_$_tapScoreController in:
/Users/Sarthak/Library/Developer/Xcode/DerivedData/Tap!-gtxtrvaffmxxtocfqejemafixgvx/Build/Intermediates/Tap!.build/Debug-iphonesimulator/Tap!.build/Objects-normal/i386/tapScoreController.o
/Users/Sarthak/Library/Developer/Xcode/DerivedData/Tap!-gtxtrvaffmxxtocfqejemafixgvx/Build/Intermediates/Tap!.build/Debug-iphonesimulator/Tap!.build/Objects-normal/i386/main.o
duplicate symbol _OBJC_IVAR_$_tapScoreController.score in:
/Users/Sarthak/Library/Developer/Xcode/DerivedData/Tap!-gtxtrvaffmxxtocfqejemafixgvx/Build/Intermediates/Tap!.build/Debug-iphonesimulator/Tap!.build/Objects-normal/i386/tapScoreController.o
/Users/Sarthak/Library/Developer/Xcode/DerivedData/Tap!-gtxtrvaffmxxtocfqejemafixgvx/Build/Intermediates/Tap!.build/Debug-iphonesimulator/Tap!.build/Objects-normal/i386/tapAppDelegate.o
duplicate symbol _OBJC_IVAR_$_tapScoreController.gameStart in:
/Users/Sarthak/Library/Developer/Xcode/DerivedData/Tap!-gtxtrvaffmxxtocfqejemafixgvx/Build/Intermediates/Tap!.build/Debug-iphonesimulator/Tap!.build/Objects-normal/i386/tapScoreController.o
/Users/Sarthak/Library/Developer/Xcode/DerivedData/Tap!-gtxtrvaffmxxtocfqejemafixgvx/Build/Intermediates/Tap!.build/Debug-iphonesimulator/Tap!.build/Objects-normal/i386/tapAppDelegate.o
duplicate symbol _OBJC_METACLASS_$_tapScoreController in:
/Users/Sarthak/Library/Developer/Xcode/DerivedData/Tap!-gtxtrvaffmxxtocfqejemafixgvx/Build/Intermediates/Tap!.build/Debug-iphonesimulator/Tap!.build/Objects-normal/i386/tapScoreController.o
/Users/Sarthak/Library/Developer/Xcode/DerivedData/Tap!-gtxtrvaffmxxtocfqejemafixgvx/Build/Intermediates/Tap!.build/Debug-iphonesimulator/Tap!.build/Objects-normal/i386/tapAppDelegate.o
duplicate symbol _OBJC_CLASS_$_tapScoreController in:
/Users/Sarthak/Library/Developer/Xcode/DerivedData/Tap!-gtxtrvaffmxxtocfqejemafixgvx/Build/Intermediates/Tap!.build/Debug-iphonesimulator/Tap!.build/Objects-normal/i386/tapScoreController.o
/Users/Sarthak/Library/Developer/Xcode/DerivedData/Tap!-gtxtrvaffmxxtocfqejemafixgvx/Build/Intermediates/Tap!.build/Debug-iphonesimulator/Tap!.build/Objects-normal/i386/tapAppDelegate.o
ld: 12 duplicate symbols for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
【问题讨论】:
你改变你的调试了吗? @sarthak 看来你的 tapScoreController 和 tapViewController 有问题。我的意思是检查声明。 你做了什么?请先指定 只需清理您的应用程序并再次执行它就会工作.. 【参考方案1】:我发现出了什么问题,我将 .h 文件导入到 viewController.h 和 view controller.m 中,这就是它不起作用的原因。
【讨论】:
以上是关于Apple Mach-O 链接器错误,目标 C的主要内容,如果未能解决你的问题,请参考以下文章
Apple Mach-O链接器错误_OBJC_CLASS _ $ _ FIRInstanceID