使用 Core Data 时的向后兼容性
有人能解释一下为什么我的应用程序在 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 链接很弱,并且将 Base SDK 设置为 3.0,将部署目标设置为 SDK 2.2
该应用程序已经使用其他3.0 功能可用时,我对这些功能没有任何问题。但显然用于其他功能的向后兼容方法不适用于 Core Data。
应用程序在调用应用程序委托的 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)
Could anybody shed some light as to why is my app crashing with the following error on 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
I have weak linked CoreData.framework, and have the Base SDK set to 3.0 and Deployment Target set to SDK 2.2
The app already uses other 3.0 features when available and I did not have any problems with those. But apparently the backward-compatibility methods used for other features do not work with Core Data.
The app crashes before app delegate's applicationDidFinishLaunching gets called.
Here's the debugger log:
[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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
显然,如果您不向后兼容 iPhone OS 2.2,则无法通过文字类符号引用 NSPredicate
因此,将我对 NSPredicate 的引用更改为:
现在它可以工作了。
请参阅https://devforums.apple.com/message/225591#225591
Apparently you can't reference NSPredicate by a literal class symbol if you won't to have backwards compatibility with iPhone OS 2.2
So changed my reference to NSPredicate to:
and it works now.
See https://devforums.apple.com/message/225591#225591
抱歉,请重新阅读您的问题。看起来框架本身不能弱链接。我想这意味着您不能使用 Core Data 框架创建 2.x 目标:(
即整个框架在目标平台上不可用,并且弱链接不适用。
Sorry, just re-read your question.. It looks like the framework itself can't be weakly linked. I guess it means you can't have a 2.x target with Core Data framework :(
i.e. the whole framework is not available on the target platform, and weak linking does not apply.