【问题标题】:Error after creation of core data files创建核心数据文件后出错
【发布时间】:2013-11-30 03:51:46
【问题描述】:

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

【问题讨论】:

  • 你有两个同名的类,即:- Asset 吗?
  • 嘿,你是对的,有 2 个同名的类,但现在当我删除这些文件时,我收到 2 个错误,请检查我编辑过的问题

标签: iphone objective-c ios


【解决方案1】:

请包含 coreData 框架 ...

【讨论】:

  • 嘿 Ali3n ...thanx .... 已解决 ... 刚刚添加了 coreData 框架并已解决
【解决方案2】:

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

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

不要碰 _Assets.h 和 _Assets.m 文件,在 Assets.h 和 Assets.m 中做所有你需要的事情。

希望对你有帮助

【讨论】:

  • 实际上我有 4 个同名的类,Assets.h Assets.m,但是在删除其中 2 个后,我遇到了更多错误,请检查我的问题,我已对其进行了编辑
  • 全部删除,让 mogenerator 为你生成这些类
  • 除此之外没有别的办法了吗?
  • @NeverEver 我不知道。每次我更改核心数据中的某些内容时,我都被教导使用 mogenerator
【解决方案3】:

添加核心数据

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

如何添加框架

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

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

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

【讨论】:

    【解决方案4】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-03-21
      • 2013-07-11
      • 1970-01-01
      • 1970-01-01
      • 2013-07-01
      • 1970-01-01
      • 2012-11-14
      相关资源
      最近更新 更多