How to prevent a Command Line Tool from exiting before asynchronous operation completes April 23, 2023 by Tarik Adding RunLoop.main.run() to the end of the file is one option. More info on another approach using a semaphore here