使用Core Data时的向后兼容性

时间:2010-05-26 00:23:44

标签: iphone cocoa-touch core-data backwards-compatibility

有没有人能说明为什么我的应用程序在iPhone OS 2.2.1上出现以下错误?

dyld: Symbol not found: _OBJC_CLASS_$_NSPredicate
  Referenced from: /var/mobile/Applications/456F243F-468A-4969-9BB7-A4DF993AE89C/AppName.app/AppName
  Expected in: /System/Library/Frameworks/Foundation.framework/Foundation

我的链接CoreData.framework很弱,基本SDK设置为3.0,部署目标设置为SDK 2.2

应用程序已经使用了其他3.0功能,我没有遇到任何问题。但显然,用于其他功能的向后兼容性方法不适用于Core Data。

在调用app delegate的applicationDidFinishLaunching之前,应用程序崩溃了。

这是调试器日志:

[Session started at 2010-05-25 20:17:03 -0400.]
GNU gdb 6.3.50-20050815 (Apple version gdb-1119) (Thu May 14 05:35:37 UTC 2009)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "--host=i386-apple-darwin --target=arm-apple-darwin".tty /dev/ttys001
Loading program into debugger…
sharedlibrary apply-load-rules all
warning: Unable to read symbols from "MessageUI" (not yet mapped into memory).
warning: Unable to read symbols from "CoreData" (not yet mapped into memory).
Program loaded.
target remote-mobile /tmp/.XcodeGDBRemote-12038-42
Switching to remote-macosx protocol
mem 0x1000 0x3fffffff cache
mem 0x40000000 0xffffffff none
mem 0x00000000 0x0fff none
run
Running…
[Switching to thread 10755]
[Switching to thread 10755]
Re-enabling shared library breakpoint 1
Re-enabling shared library breakpoint 2
Re-enabling shared library breakpoint 3
Re-enabling shared library breakpoint 4
Re-enabling shared library breakpoint 5
(gdb) continue
warning: Unable to read symbols for ""/Users/alex/iPhone Projects/AppName/build/Debug-iphoneos"/AppName.app/AppName" (file not found).
dyld: Symbol not found: _OBJC_CLASS_$_NSPredicate
  Referenced from: /var/mobile/Applications/456F243F-468A-4969-9BB7-A4DF993AE89C/AppName.app/AppName
  Expected in: /System/Library/Frameworks/Foundation.framework/Foundation

(gdb) 

2 个答案:

答案 0 :(得分:1)

如果您不想向后兼容iPhone OS 2.2,则无法通过文字类符号引用NSPredicate

所以我将对NSPredicate的引用改为:

[fetchRequest setPredicate:[NSClassFromString(@"NSPredicate") predicateWithFormat:@"EntryId == %@", [NSNumber numberWithInt: index]]];

现在有效。

请参阅https://devforums.apple.com/message/225591#225591

答案 1 :(得分:0)

抱歉,只是重新阅读你的问题..看起来框架本身不能弱链接。我想这意味着你不能拥有Core Data框架的2.x目标:(

即。整个框架在目标平台上不可用,弱链接不适用。