自定义键盘在App Store中崩溃,但从Xcode启动时不会崩溃 [英] Custom keyboard crashes in App Store, but not in when launched from 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
进行编码,因此,只要用户使用的是应用中的键盘扩展名.
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:
之类的奇特调用时,我建议您审核应用程序的代码并将其删除.也许将全部 UIAppearance
调用调为无操作,在TestFlight中推升内部beta,然后查看问题是否已解决,以确认这是问题所在.
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
中运行应用程序(您可以通过转到product-> scheme-> edit scheme打开此功能),方法是添加一行代码来进行设置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屋!