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()returnsfalse, 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!