Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash with iOS Simulator #4

Open
ds8k opened this issue Oct 11, 2016 · 6 comments
Open

Crash with iOS Simulator #4

ds8k opened this issue Oct 11, 2016 · 6 comments

Comments

@ds8k
Copy link

ds8k commented Oct 11, 2016

Getting this crash when attempting to build to the simulator in Xcode 8:

2016-10-11 13:39:03.972 App[99718:5081501] *** Assertion failure in -[KeychainItemWrapper writeToKeychain], KeychainItemWrapper.m:325
2016-10-11 13:39:03.985 App[99718:5081501] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Couldn't add the Keychain Item.'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010e50f34b __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x000000010df4721e objc_exception_throw + 48
    2   CoreFoundation                      0x000000010e513442 +[NSException raise:format:arguments:] + 98
    3   Foundation                          0x000000010a37fedd -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 195
    4   App                                0x0000000108c94aaa -[KeychainItemWrapper writeToKeychain] + 970
    5   App                                0x0000000108c93e9a -[KeychainItemWrapper setObject:forKey:] + 218
    6   App                                0x0000000108c9178e -[SecureLocalStorage writeToSecureStorage:] + 270
    7   App                                0x0000000108c9378b __37-[SecureLocalStorage clearIfInvalid:]_block_invoke + 635
    8   libdispatch.dylib                   0x000000010ff90980 _dispatch_call_block_and_release + 12
    9   libdispatch.dylib                   0x000000010ffba0cd _dispatch_client_callout + 8
    10  libdispatch.dylib                   0x000000010ff99366 _dispatch_queue_override_invoke + 1426
    11  libdispatch.dylib                   0x000000010ff9b3b7 _dispatch_root_queue_drain + 720
    12  libdispatch.dylib                   0x000000010ff9b08b _dispatch_worker_thread3 + 123
    13  libsystem_pthread.dylib             0x0000000110334746 _pthread_wqthread + 1299
    14  libsystem_pthread.dylib             0x0000000110334221 start_wqthread + 13
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 
@dickverweij
Copy link
Owner

Hmm.. strange.. we will investigate..

@PhilHuot
Copy link

Hi, I have the same issue. I think It's only for iOS10, iOS9 lower work fine.

@ds8k
Copy link
Author

ds8k commented Oct 19, 2016

I have a crappy work-around:

#if TARGET_IPHONE_SIMULATOR
#else
        // No previous item found; add the new one.
        result = SecItemAdd((__bridge CFDictionaryRef)[self dictionaryToSecItemFormat:keychainItemData], NULL);
        NSAssert( result == noErr, @"Couldn't add the Keychain Item." );
#endif

At the very least this lets me test other features out in the simulator

@tabrindle
Copy link

tabrindle commented Oct 19, 2016

A very slightly less crappy workaround:

#if !TARGET_OS_SIMULATOR
        // No previous item found; add the new one.
        result = SecItemAdd((__bridge CFDictionaryRef)[self dictionaryToSecItemFormat:keychainItemData], NULL);
        NSAssert( result == noErr, @"Couldn't add the Keychain Item." );
#endif

This gets rid of the useless else and uses a non-deprecated macro.

That said, a similar plugin seems to have this working without crashing, but also seems to have a lot of conditional code for simulators: https://github.com/driftyco/cordova-plugin-ios-keychain

EDIT: I did some research on the library you are using KeychainItemWrapper.m and it seems there is an open bug for the iOS 10 simulator - https://forums.developer.apple.com/thread/51071.

It also seems that the workaround is relatively simple for native projects - to enable keychain sharing in Xcode.

It's slightly more complicated for cordova projects - you may need to integrate the entitlement hook from this plugin https://github.com/Telerik-Verified-Plugins/Keychain-Sharing.

@dickverweij
Copy link
Owner

just went to xcode 8.. so i got to fix this

@tabrindle
Copy link

According the the apple forums relating to that keychain library you are using, the easiest way to fix this is to enable keychain sharing. If you can implement this as part of your plugin, I think this would be a decent work around until it is fixed up stream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants