创建核心数据文件后出错

时间:2012-01-17 12:33:44

标签: iphone objective-c ios

我已经开始将核心数据添加到我的应用程序中。我创建了名为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)

4 个答案:

答案 0 :(得分:10)

请包含coreData框架......

答案 1 :(得分:0)

我不会自己创建这些类。我建议您删除它们并使用mogenerator为您完成。它将为每个实体创建4个类。在您的示例中,它将是:

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

不要触及_Assets.h和_Assets.m文件,在Assets.h和Assets.m中执行所需的操作。

希望有所帮助

答案 2 :(得分:0)

添加核心数据

您需要按照Ali3n的建议添加核心数据框架。

如何添加框架

如果您不知道如何向项目添加框架,请执行以下操作:

  
      
  1. 在项目导航器中,选择您的项目
  2.   
  3. 选择目标
  4.   
  5. 选择“构建阶段”标签
  6.   
  7. 使用库扩展程序打开'链接二进制文件
  8.   
  9. 点击“+”按钮
  10.   
  11. 选择您的框架
  12.   
  13. (可选)将添加的框架拖放到“框架”组
  14.   

enter image description here

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

答案 3 :(得分:0)

我收到了链接器错误,因为我只将“人”文件导入到我的项目而不是“机器”文件中。