How to disable dimming on the screen, and print os_log on the content screen

I have created an iOS .ipa file to run some tests, and all the test cases have os_log implemented for tracing. However, there is an issue; my tests take over 20 seconds to run, and the screen starts to dim. Consequently, the execution stops. Once I reactivate the screen, the tests resume. I added [UIApplication.sharedApplication setIdleTimerDisabled:YES]; to the code, but it doesn't resolve the problem.

I've used os_log to trace all the test case results. I wonder if it's possible to display all the os_log messages from runTest on the app main screen as well.

int main(int argc, char** argv) {
	
    //Separate thread to runTest, os_log implemented there
	std::thread thread_obj(runTests, argc, argv);

	int applicationReturn;
	@autoreleasepool {
         [UIApplication.sharedApplication setIdleTimerDisabled:YES];
         applicationReturn = UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
	}

    thread_obj.join();
    [UIApplication.sharedApplication setIdleTimerDisabled:NO];
    return applicationReturn;
}

Are you sure the setIdleTimerDisabled code is executing? It is my understanding that the call to UIApplicationMain() never returns.

And then I realize I was looking at the code you had to reenable the timer. You might want to consider moving the code into the app delegate. I've used the disable timer successfully in a media program to prevent the app locking while playing videos since the user wouldn't be interacting with the phone.

You might want to consider moving the code into the app delegate.

Right. Doing stuff in main on iOS is always a bit weird. It works in many situations but, because everything on iOS is an app, it’s easy to run into subsystem that expect that expect to be run from an app context.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

How to disable dimming on the screen, and print os_log on the content screen
 
 
Q