自定义键盘在 App Store 中崩溃,但从 Xcode 启动时不会崩溃 [英] Custom keyboard crashes in App Store, but not in when launched from Xcode

查看:32
本文介绍了自定义键盘在 App Store 中崩溃,但从 Xcode 启动时不会崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现从 Xcode 启动时,安装和使用自定义键盘对我的应用程序很有效,但是如果我将它发布到 TestFlight 或 AppStore,那么当用户单击文本框并尝试调出键盘时它会崩溃.据我所知,我的应用程序中的任何文本框都没有什么特别之处.堆栈跟踪是:

I have found that installing and using custom keyboard works fine for my app when launching from Xcode, but if I release it to TestFlight or the AppStore then it crashes when a user clicks on a textbox and tries to bring up the keyboard. As far as I am aware there is nothing special about any of the textboxes in my app. The stack trace is:

Thread : Fatal Exception: NSInternalInconsistencyException
0  CoreFoundation                 6512725832 __exceptionPreprocess
1  libobjc.A.dylib                6869942144 objc_exception_throw
2  CoreFoundation                 6512725528 +[NSException raise:format:]
3  Foundation                     6528403996 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:]
4  UIKit                          6606881444 -[UIColor encodeWithCoder:]
5  Foundation                     6528169072 _encodeObject
6  Foundation                     6528197336 +[NSKeyedArchiver archivedDataWithRootObject:]
7  UIKit                          6609904352 -[_UIAppearanceRecorder _recordInvocation:withClassName:containerClassNames:traitCollection:selectorString:forRemoteProcess:]
8  UIKit                          6609884356 __54+[_UIAppearance _recordersExcludingSource:withWindow:]_block_invoke
9  CoreFoundation                 6511594744 __65-[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:]_block_invoke
10 CoreFoundation                 6511594448 -[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:]
11 UIKit                          6609883592 +[_UIAppearance _recordersExcludingSource:withWindow:]
12 UIKit                          6611900724 UIViewServiceCurrentAppearanceSerializedRepresentations
13 UIKit                          6610654700 +[_UIRemoteViewController _requestViewController:traitCollection:fromServiceWithBundleIdentifier:service:connectionHandler:]
14 UIKit                          6610654160 +[_UIRemoteViewController requestViewControllerWithService:connectionHandler:]
15 UIKit                          6609355772 __117-[NSExtension(UIViewControllerAdditions) instantiateViewControllerWithInputItems:listenerEndpoint:connectionHandler:]_block_invoke_2
16 libdispatch.dylib              6878402280 _dispatch_call_block_and_release
17 libdispatch.dylib              6878402216 _dispatch_client_callout
18 libdispatch.dylib              6878424496 _dispatch_main_queue_callback_4CF
19 CoreFoundation                 6512427512 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
20 CoreFoundation                 6512418912 __CFRunLoopRun
21 CoreFoundation                 6511561888 CFRunLoopRunSpecific
22 GraphicsServices               6701891720 GSEventRunModal
23 UIKit                          6602887164 UIApplicationMain
24 MyApp                          4296179280 main (main.m:16)
25 libdyld.dylib                  6878603448 start

查看实时设备控制台,我看到以下消息:

Looking at the live device console I see the following messages:

Dec  8 15:22:11 cjhills-iPhone poc[371] <Error>: *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Only RGBA or White color spaces are supported in this situation.'
    *** First throw call stack:
    (0x18244cf48 0x1978f7f80 0x18244ce18 0x183340a1c 0x187e182a4 0x183307470 0x18330e2d8 0x1880fa2e0 0x1880f54c4 0x182338cf8 0x182338bac 0x1880f51c8 0x1882e1934 0x1881b15ec 0x1881b13d0 0x1880743fc 0x1981096e8 0x1981096a8 0x19810edb0 0x1824041f8 0x182402060 0x182330ca0 0x18d8b4088 0x187a48ffc 0x10014e434 0x19813a8b8)
Dec  8 15:22:11 cjhills-iPhone SpringBoard[58] <Warning>: HW kbd: Failed to set (null) as keyboard focus
Dec  8 15:22:11 cjhills-iPhone SpringBoard[58] <Warning>: HW kbd: Failed to set (null) as keyboard focus
Dec  8 15:22:11 cjhills-iPhone SwiftKey[337] <Warning>: host connection <NSXPCConnection: 0x14ce60290> connection from pid 371 invalidated
Dec  8 15:22:11 cjhills-iPhone SpringBoard[58] <Warning>: UNNotificationRegistrarConnectionListener connection invalidated
Dec  8 15:22:11 cjhills-iPhone com.apple.xpc.launchd[1] (UIKitApplication:com.cjhill.myapp[0x5a38][371]) <Notice>: Service exited due to signal: Abort trap: 6
Dec  8 15:22:11 cjhills-iPhone diagnosticd[85] <Error>: unable to find offset 0x9812fa5c in shared cache for arch 'arm64'
Dec  8 15:22:11 cjhills-iPhone ReportCrash[372] <Notice>: platform_thread_get_unique_id matched 66610
Dec  8 15:22:11 cjhills-iPhone ReportCrash[372] <Notice>: Formulating report for corpse[371] myapp
Dec  8 15:22:11 cjhills-iPhone ReportCrash[372] <Warning>: saved type '109_myapp' report (2 of max 25) as /var/mobile/Library/Logs/CrashReporter/myapp_2015-12-08-152211_cjhills-iPhone.ips
Dec  8 15:22:11 cjhills-iPhone SpringBoard[58] <Warning>: Application 'UIKitApplication:com.cjhill.myapp[0x5a38]' crashed.
Dec  8 15:22:11 cjhills-iPhone UserEventAgent[26] <Warning>: 549612077011: id=com.cjhill.myapp pid=371, state=0

推荐答案

从堆栈跟踪中可以看出,您使用 UIAppearance 代理来设置应用程序的外观.

It appears from the stack trace that you use UIAppearance proxies to set up your App's appearance.

iOS 扩展的一个有趣的怪癖是,使用此 API 在其他应用中进行的自定义实际上会传递给应用中包含的扩展(至少在键盘扩展的情况下).

An interesting quirk of iOS extensions is that the customizations made in the other apps using this API are actually passed to extensions contained in the app (at least in the case of keyboard extensions).

为确保安全,所有传递的对象都必须使用 NSSecureCoding 进行编码,因此要求您在 UIAppearance 中使用的任何对象都必须符合此协议(并实际履行其承诺),只要用户在您的应用中使用键盘扩展.

To ensure security, all objects passed must be encoded using NSSecureCoding, which therefore requires that any objects you use in UIAppearance must conform to this protocol (and actually fulfill what it promises), as long as a user is using a keyboard extension in your app.

在这种情况下,您的应用似乎正在尝试传递无法存档的颜色.也许您正在使用 +[UIColor colorWithPatternImage:] 将图像用作颜色,这将符合错误 - 图像可能没有 UIColor 意义上的颜色.

It appears that your app in this case is attempting to pass a color which can't be archived. Perhaps you are using an image as a color using +[UIColor colorWithPatternImage:], which would fit the error -- an image probably has no color in the sense UIColor means.

我建议您在任何使用 UIAppearance 设置颜色的情况下审核您的应用代码,尤其是在使用诸如 colorWithPatternedImage: 之类的特殊调用时,并删除它们.也许 swizzle all UIAppearance 调用无操作,推一个内部在 TestFlight 中进行测试,然后查看问题是否已解决以确认是否是此问题.

I recommend you audit your app's code for any instances where a UIAppearance is used to set a color, particularly when exotic calls like colorWithPatternedImage: are used, and remove them. Perhaps swizzle all UIAppearance calls to no-ops, push up an internal beta in TestFlight, and see if the problem is solved to confirm that this is the issue.

无论是哪种情况:向 Apple 提交错误.应用程序不应该仅仅因为它们无法正确编码它们的 UIAppearance 而崩溃,尤其是在做一些坦率地说,不受欢迎的事情时.

Regardless of which of these it is: File a bug with Apple. Apps should not crash just because they can't encode their UIAppearance correctly, especially when doing something that is, frankly, undesirable.

可以在不使用 TestFlight 的情况下重现此问题,同时在 release 中运行应用程序(您可以通过添加将 UIButton 的背景颜色设置为图案颜色的 UIColor 的代码行,然后调用键盘扩展.

it is possible to reproduce this issue without using TestFlight, whilst running an app in release (you can turn this on by going to product->scheme->edit scheme) by adding a line of code to set the background color of a UIButton to a UIColor which is a patterned color, then invoking a keyboard extension.

这篇关于自定义键盘在 App Store 中崩溃,但从 Xcode 启动时不会崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆