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