#SecureStorage not working on iOS Simulator

1 messages Β· Page 1 of 1 (latest)

pastel narwhal
#

Environment:

  • NativePHP Mobile
  • iOS Simulator (Xcode)
  • Laravel 12

Issue:
SecureStorage::set() returns false on the iOS Simulator and data is never persisted. SecureStorage::get() always returns null.

$result = SecureStorage::set('auth_token', $data['token']);
dd($result); // returns false on simulator

Root Cause:
SecureStorage uses the iOS Keychain under the hood, which does not work properly in the iOS Simulator. The Keychain is a hardware-level security feature that requires a real physical device to function correctly.

Confirmed behavior:

  • ❌ iOS Simulator β†’ SecureStorage::set() returns false, data not stored
  • βœ… Real iPhone/iPad β†’ Works as expected

Workaround for local development (Simulator):

// Use session() as fallback when running on simulator
if (app()->environment('local')) {
    session(['auth_data' => json_encode($data)]);
} else {
    SecureStorage::set('data', json_encode($data));
}

Question:
Is this expected behavior? Is there any plan to support SecureStorage in the iOS Simulator for development purposes? Or is the recommended approach to always test SecureStorage on a real device?

Thanks!

waxen wadi
#

Running the app on Xcode and looking at the log might be helpful in telling what is going on

subtle prairie
pastel narwhal
pastel narwhal
#

Fixed! The plugins were not registered. After registering them, everything works fine on the iOS emulator. Thanks for your help! πŸ‘

waxen wadi