Reputation: 1054
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
Upvotes: 1
Views: 2427
Reputation: 4805
It appears from the stack trace that you use UIAppearance
proxies to set up your App's appearance.
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).
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.
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.
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.
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.
EDIT: 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.
Upvotes: 3