Search code examples
iosmauirider

Keep iPhone Unlocked while Debugging with Rider


I'm writing an app using MAUI. When debugging with Rider, if the iPhone locks, the debug link drops. Which is annoying.

Now, I know I can set my phone to not auto-lock. However, crucially, it's my phone not a work phone and I don't want to have to change it every day.

Is there any way to prevent the device auto-locking when I'm debugging?


Solution

  • You could turn the screen on for debugging.

    Under debug, invoke this method:

    #if DEBUG
    public void ToggleScreenLock()
    {
        DeviceDisplay.KeepScreenOn = !DeviceDisplay.KeepScreenOn;
    }
    #endif
    

    It should be on the main thread.