神秘的error code: -42028

这是几个月前在iOS app开发中碰到的错误,app的测试版、ad hoc版都没有问题,提交到app store后安装会闪退,crash log如下(app相关信息已做虚化处理):

Oct 11 11:47:11 unknown SpringBoard[15] <Warning>: Unable to obtain a task
name port right for pid 317: (os/kern) failure
Oct 11 11:47:11 unknown com.apple.launchd[1] <Notice>:
(UIKitApplication:com.******.******[0x6c35]) Exited: Killed: 9
Oct 11 11:47:11 unknown com.apple.launchd[1] <Warning>:
(UIKitApplication:com.******.******[0x6c35]) Throttling respawn: Will
start in 2147483647 seconds
Oct 11 11:47:11 unknown SpringBoard[15] <Warning>: Application ‘********’
-e-x-i-t-e-d -a-b-n-o-r-m-a-l-l-y -w-i-t-h -s-i-g-n-a-l -9-: -K-i-l-l-e-d-:
-9
Oct 11 11:47:11 unknown kernel[0] <Debug>:
AppleFairplayTextCrypterSession::fairplayOpen() failed, error -42028

问题定位到了AppleFairplayTextCrypterSession::fairplayOpen()函数,但寻遍了google的所有结果也没有任何跟错误代码-42028有关的信息( 在这篇文章发表后就不同了;-) )。因为这个app是基于Adobe air 3开发的,很多东西都处于黑盒状态。屡试无果后,向apple technical support求助(BTW:所有花了99$或299$的开发者们,你是否知道每年的年费里包含者若干次免费的技术支持呢?)。 经过一番沟通,弄清楚了整个问题的所在:应用本身编译后的可执行文件太大(当然仍小于app store对文件大小的限制),该问题在开发时并不会出现,因为在整个开发过程中,app二进制文件不会被加密;当上传到苹果商店后,用户所安装的版本是一个经过加密的二进制文件,打开时会有一个解密的步骤,当二进制文件太大时,fairplay内存耗尽,就报错了。对app进行技术瘦身后问题迎刃而解。

For english readers:

> kernel[0] <Debug>: AppleFairplayTextCrypterSession::fairplayOpen() failed, error -42028

This error is happening because the FairPlay daemon is running out of memory when trying to decrypt your app’s executable. You aren’t seeing this happen during development, because the encryption is only applied by the store, not Xcode. So try to lower your executable size and the problem will be fixed. :)