When I run a Swift package with swift run, the I/O behaves weird. There can be shell prompts mixed in with the output, the input is sometimes parsed by the shell and not sent to the application, and the cursor can jump to different positions on the screen.
Here is a sample main.swift you can try:
Note that the application behaves correctly when I run the executable directly. It is only when I use swift run that I see these issues.