2012-01-17 96 views
4

我已經開始向我的應用程序添加核心數據。我創建了名爲Assets的實體並定義了它的四個屬性,然後爲NSManagedObject創建了Asset.h和Asset.m文件。現在,我收到以下錯誤,而在此之前,我的應用程序工作正常創建核心數據文件後出錯

Ld /Users/Omer/Library/Developer/Xcode/DerivedData/LoginTest-enoqygjnncuapjescysdafbighag/Build/Products/Debug-iphonesimulator/LoginTest.app/LoginTest normal i386 
cd /Users/Omer/Desktop/Docs/LoginTest 
setenv MACOSX_DEPLOYMENT_TARGET 10.6 
setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin" 
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/clang -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk -L/Users/Omer/Library/Developer/Xcode/DerivedData/LoginTest-enoqygjnncuapjescysdafbighag/Build/Products/Debug-iphonesimulator -L/Users/Omer/Desktop/Docs/LoginTest/ZBarSDK -F/Users/Omer/Library/Developer/Xcode/DerivedData/LoginTest-enoqygjnncuapjescysdafbighag/Build/Products/Debug-iphonesimulator -filelist /Users/Omer/Library/Developer/Xcode/DerivedData/LoginTest-enoqygjnncuapjescysdafbighag/Build/Intermediates/LoginTest.build/Debug-iphonesimulator/LoginTest.build/Objects-normal/i386/LoginTest.LinkFileList -mmacosx-version-min=10.6 -Xlinker -objc_abi_version -Xlinker 2 -Xlinker -no_implicit_dylibs -D__IPHONE_OS_VERSION_MIN_REQUIRED=50000 -liconv -framework QuartzCore -framework CoreVideo -framework CoreMedia -framework AVFoundation -framework MapKit -framework CoreLocation -lz -framework CoreGraphics -framework MobileCoreServices -framework SystemConfiguration -framework CFNetwork -framework Foundation -framework UIKit -lzbar -o /Users/Omer/Library/Developer/Xcode/DerivedData/LoginTest-enoqygjnncuapjescysdafbighag/Build/Products/Debug-iphonesimulator/LoginTest.app/LoginTest 


Undefined symbols for architecture i386: 


"_OBJC_METACLASS_$_NSManagedObject", referenced from: 
    _OBJC_METACLASS_$_Asset in Asset.o 


"_OBJC_CLASS_$_NSManagedObject", referenced from: 
    _OBJC_CLASS_$_Asset in Asset.o 
ld: symbol(s) not found for architecture i386 
clang: error: linker command failed with exit code 1 (use -v to see invocation) 
+0

你有兩個同名的類:即資產? – Ali3n 2012-01-17 12:39:47

+0

嘿你是對的,有2個同名的班級,但現在當我刪除這些文件時,我收到2個錯誤,請檢查我編輯過的問題 – 2012-01-17 12:45:39

回答

10

請包括coreData框架...

+1

嘿Ali3n ... thanx ....它的解決...只是增加了coreData框架和它的解決方案 – 2012-01-17 17:21:14

0

我不會創建這些類自己。我的「D建議你將其刪除,並使用mogenerator來爲你做這將創建4類爲每個實體在您的例子將是:。

_Assets.h 
_Assets.m 
Assets.h 
Assets.m 

不碰_Assets.h和_assets .m文件,你在Assets.h和Assets.m需要做的一切。

希望它可以幫助

+0

實際上我有4個班級名稱相同,名爲Assets。 h Assets.m,但刪除其中2個後,我得到更多的錯誤,請檢查我的問題,我已編輯它 – 2012-01-17 12:48:20

+0

刪除它們,讓mogenerator爲你生成這些類 – Novarg 2012-01-17 12:50:08

+0

有沒有解決方案,除此? – 2012-01-17 12:52:40

0

添加核心數據

您需要按照Ali3n的建議添加核心數據框架。

如何添加框架

如果你不知道如何將框架添加到項目中執行以下操作:

  1. 在項目導航器中,選擇您的項目
  2. 選擇您的目標
  3. 選擇'Build Phases'選項卡
  4. 打開'Lin' ķ二進制文件庫擴展
  5. 點擊 '+' 按鈕
  6. 選擇框架
  7. (可選)拖放添加的框架拖放到 '框架' 組

enter image description here

鏈接到原始帖子:How to "add existing frameworks" in Xcode 4?

0

我得到了鏈接器錯誤,因爲我o只能將「人」文件導入到我的項目中,而不是「機器」文件。