Skip to content

CHANGE build-and-run.sh to reuse Simulator instance#7

Open
ninovanhooff wants to merge 4 commits intofinnvoor:mainfrom
ninovanhooff:fix/simulator-reuse
Open

CHANGE build-and-run.sh to reuse Simulator instance#7
ninovanhooff wants to merge 4 commits intofinnvoor:mainfrom
ninovanhooff:fix/simulator-reuse

Conversation

@ninovanhooff
Copy link

problem

On MacOS, using vs code, my issue was that the simulator was completely hidden by the VS code window when running the task Playdate: run (debug)

solution

  • By not quitting the Simulator, window position is retained
  • by using the open command, the Simulator window receives focus

@finnvoor
Copy link
Owner

.swiftpm/build-and-run.sh was really just made to support building and running from Xcode, and launching the simulator executable directly is what allows the console to be viewed in Xcode (and closing the simulator on exit matches existing Xcode conventions). So I don't think this should be merged, but I believe VSCode has some kind of tasks system for defining build/run commands. If you want to add a slightly modified version of build-and-run.sh as a vscode task and open a PR I'm happy to merge that.

@finnvoor
Copy link
Owner

ah sorry I forget there already is a vscode task that calls build and run. I think we can just update that to use an alternate script, or inline this change into the task

@ninovanhooff
Copy link
Author

ninovanhooff commented Feb 15, 2026

@finnvoor ok, I made that explicit by renaming the file and creating a new one for vscode.

With this change, we indeed lose seeing the logs in the terminal, but I don't consider that a loss. The developer can open the Console window from within the running Simulator and position it as they like. This persists multiple runs since the simulator is not restarted. Restarting the simulator takes significant time, perhaps more than 2 seconds.

Also, by using open, the Simulator will be launched in a separate process, which allows the build task to end. Vscode expects this. When you use the "Relaunch last task" command, vscode asks for confirmation to kill any running tasks before restarting the task, which is another hurdle for quick iteration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants