capacitor icon indicating copy to clipboard operation
capacitor copied to clipboard

Secure Storage crash ios

Open ryan29871 opened this issue 7 years ago • 3 comments

Description of the problem: We have an ionic project using Capacitor along with cordova-plugin-secure-storage. We have a service that calls const storage = await this.secureStorage.create('ss'); const keys = await storage.keys(); When the application is loaded to a phone or simulator the app crashes at 'await storage.keys()' and throws..

2019-09-09 11:58:52.117823-0400 App[90553:13766957] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSBundle initWithURL:]: nil URL argument' *** First throw call stack: ( 0 CoreFoundation 0x00000001057068db __exceptionPreprocess + 331 1 libobjc.A.dylib 0x00000001037c8ac5 objc_exception_throw + 48 2 CoreFoundation 0x0000000105706735 +[NSException raise:format:] + 197 3 Foundation 0x00000001031f7175 -[NSBundle initWithURL:] + 87 4 Foundation 0x00000001031f7224 +[NSBundle bundleWithURL:] + 45 5 CordovaPlugins 0x0000000101afa167 __34+[SAMKeychainQuery errorWithCode:]_block_invoke + 183 6 libdispatch.dylib 0x000000010cd6adb5 _dispatch_client_callout + 8 7 libdispatch.dylib 0x000000010cd6c83c _dispatch_once_callout + 66 8 CordovaPlugins 0x0000000101af99ac +[SAMKeychainQuery errorWithCode:] + 156 9 CordovaPlugins 0x0000000101af8f35 -[SAMKeychainQuery fetchAll:] + 373 10 CordovaPlugins 0x0000000101afbbdf __22-[SecureStorage keys:]_block_invoke + 191 11 libdispatch.dylib 0x000000010cd69d7f _dispatch_call_block_and_release + 12 12 libdispatch.dylib 0x000000010cd6adb5 _dispatch_client_callout + 8 13 libdispatch.dylib 0x000000010cd6d7b9 _dispatch_queue_override_invoke + 1022 14 libdispatch.dylib 0x000000010cd7b632 _dispatch_root_queue_drain + 351 15 libdispatch.dylib 0x000000010cd7bfca _dispatch_worker_thread2 + 130 16 libsystem_pthread.dylib 0x000000010d14c6b3 _pthread_wqthread + 583 17 libsystem_pthread.dylib 0x000000010d14c3fd start_wqthread + 13

It seems like the plugin itself is having trouble locating the path to SAMKeychain.bundle

Affected platform

  • [ ] iOS

OS of the development machine

  • [ ] macOS

Capacitor version: 1.1.1

node version: 10.16.0

npm version: 6.9.0

CocoaPods version: 1.7.5

Steps to reproduce: Create a new ionic project. Install Capacitor install cordova-plugin-secure-storage

Add to project and run project. const storage = await this.secureStorage.create('ss'); const keys = await storage.keys();

ryan29871 avatar Sep 09 '19 17:09 ryan29871

Any progress on this?

vhinic avatar Oct 28 '19 20:10 vhinic

The problem is [NSBundle bundleForClass:[self class]], since Capacitor uses CocoaPods, the bundle is moved to the main bundle, so the plugin code should be changed to [NSBundle mainBundle].

We can make the CLI patch that code

jcesarmobile avatar Oct 29 '19 16:10 jcesarmobile

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.

ionitron-bot[bot] avatar Nov 13 '22 14:11 ionitron-bot[bot]