如果我链接在iOS 7中引入的MultipeerConnectivity框架并且我在iOS 6上运行我的应用程序,我在启动时会遇到预期的崩溃:
dyld: Library not loaded: /System/Library/Frameworks/MultipeerConnectivity.framework/MultipeerConnectivity Referenced from: /var/mobile/Applications/5AB83411-CEFC-437D-88F8-6B80C36CCE9F/MyApp.app/MyApp Reason: image not found
解决方法
otool -L -arch armv7 MyApp MyApp: /System/Library/Frameworks/JavaScriptCore.framework/JavaScriptCore (compatibility version 1.0.0,current version 537.51.2) /System/Library/Frameworks/UIKit.framework/UIKit (compatibility version 1.0.0,current version 2935.137.0) ...
将JavaScriptCore框架与iOS 6部署目标链接时,应用程序链接到PrivateFrameworks / JavaScriptCore.framework:
otool -L -arch armv7 MyApp MyApp: /System/Library/PrivateFrameworks/JavaScriptCore.framework/JavaScriptCore (compatibility version 1.0.0,current version 2935.137.0) ...
这是因为JavaScriptCore框架有special symbols,它指示链接器根据部署目标版本更改其dylib安装路径:
nm JavaScriptCore.framework/JavaScriptCore | grep '\$ld\$' 00000000003959a0 S $ld$install_name$os4.3$/System/Library/PrivateFrameworks/JavaScriptCore.framework/JavaScriptCore 00000000003959a1 S $ld$install_name$os5.0$/System/Library/PrivateFrameworks/JavaScriptCore.framework/JavaScriptCore 00000000003959a2 S $ld$install_name$os5.1$/System/Library/PrivateFrameworks/JavaScriptCore.framework/JavaScriptCore 00000000003959a3 S $ld$install_name$os6.0$/System/Library/PrivateFrameworks/JavaScriptCore.framework/JavaScriptCore 00000000003959a4 S $ld$install_name$os6.1$/System/Library/PrivateFrameworks/JavaScriptCore.framework/JavaScriptCore
JavaScriptCore框架在iOS 4.3到6.1的PrivateFrameworks目录中可用,因此应用程序在启动时可以找到它.在iOS 7上,PrivateFrameworks / JavaScriptCore.framework是Frameworks / JavaScriptCore.framework的符号链接,因此应用程序可以在iOS 6和7上运行.
虽然没有在任何地方记录,但这显然是Apple的一个故意转移,以向JavaScriptCore框架添加向后兼容性.但遗憾的是,App Store验证团队没有收到来自JavaScriptCore团队的应用程序和连接JavaScriptCore框架以及针对iOS 7 will be rejected以下的iOS的应用程序,因为他们使用的是PrivateFrameworks目录中的框架.如果您希望Apple解决此问题,请复制rdar://problem/17076670.
在此期间,您可以通过从项目中删除JavaScriptCore框架并使用以下其他链接器标志来解决拒绝问题(适应您获得的每个未定义的符号错误)
-Wl,-U,_JSGlobalContextCreate -Wl,_JSGlobalContextRelease
这告诉链接器动态解析符号.由于JavaScriptCore框架总是通过UIKit→WebKit→JavaScriptCore间接加载,因此符号将在运行时解析得很好,并且不应拒绝您的应用程序,因为它不再显式链接JavaScriptCore框架.