Apple Mach-O-Linker(ID)错误

时间:2012-04-12 01:57:29

标签: iphone objective-c xcode

我在我正在处理的项目中添加了一个名为RootViewController的现有类。该项目第一次编译,但第二次我尝试运行它时出现了mach-o-linker错误。我没有更改任何代码,所以我真的不知道什么是错的。我知道这个错误通常是因为缺少框架,但我很确定我包含了我需要的所有框架。

这是日志:

Ld /Users/myusername/Library/Developer/Xcode/DerivedData/coredataproject-dhlbawbtzwdgohaczdnalonzhnhs/Build/Products/Debug-iphonesimulator/coredataproject.app/coredataproject normal i386
cd /Users/myusername/Desktop/coredataproject
setenv MACOSX_DEPLOYMENT_TARGET 10.6
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/iPhoneSimulator5.0.sdk -L/Users/myusername/Library/Developer/Xcode/DerivedData/coredataproject-dhlbawbtzwdgohaczdnalonzhnhs/Build/Products/Debug-iphonesimulator -F/Users/myusername/Library/Developer/Xcode/DerivedData/coredataproject-dhlbawbtzwdgohaczdnalonzhnhs/Build/Products/Debug-iphonesimulator -filelist /Users/myusername/Library/Developer/Xcode/DerivedData/coredataproject-dhlbawbtzwdgohaczdnalonzhnhs/Build/Intermediates/coredataproject.build/Debug-iphonesimulator/coredataproject.build/Objects-normal/i386/coredataproject.LinkFileList -mmacosx-version-min=10.6 -Xlinker -objc_abi_version -Xlinker 2 -fobjc-arc -Xlinker -no_implicit_dylibs -D__IPHONE_OS_VERSION_MIN_REQUIRED=50000 -framework UIKit -framework Foundation -framework CoreGraphics -framework CoreData -framework CoreLocation -framework MapKit -o /Users/myusername/Library/Developer/Xcode/DerivedData/coredataproject-dhlbawbtzwdgohaczdnalonzhnhs/Build/Products/Debug-iphonesimulator/coredataproject.app/coredataproject

Undefined symbols for architecture i386:
  "_OBJC_CLASS_$_RootViewController", referenced from:
      objc-class-ref in FirstViewController.o
      objc-class-ref in AppDelegate.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

我已经搜索了几个小时试图找到缺失的链接或参考,但我没有看到任何错误。 任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:1)

我刚修好了。我从RootViewController中复制了代码,完全删除了.h和.m文件,创建了新文件并将名称更改为RootViewController并将代码粘贴回来。然后编译。