multiple Solar2D instances on iOS?

Oddly, I’ve noticed this for a long time and never mentioned it, but here is my code to try and prevent the issue, but it’s not working.

main.lua

if not _G.startedAlready then. -- "not" tests for the variable to be "nil"
   _G.startedAlready=1
   print("Game starts")
   startGame(). --runs multiple times, after setting _G.startedAlready=1
end

Does anyone know why this code will run numerous times (multiple instances) on my iOS device? I’m seeing “Game starts” from the print statement numerous times in the iOS Console.

FYI, this issue does not and has never occurred in the simulator on my Mac.

And this issue does not occur on Android, either. Just tested to be sure.

I have to wonder if this issue is somehow related to the fact that my iOS code continues to operate, even when we suspend the app

My guess would be that it’s not actually running twice, but is a weird bug in the Console app (or whatever you are using to view the output) where the logging is being shown multiple times per print call.

1 Like

@alanFlickGames at the moment, I can’t duplicate the problem, so you may be correct :slight_smile: Thank you.