且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在MacOS上将Vapor编译为独立应用程序

更新时间:2023-10-15 23:46:34

我认为,至少最初,您必须安装Xcode才能构建蒸气应用程序,而只是为了获取Swift东西.完成此操作后,使用终端进入蒸气项目目录,然后使用以下命令构建并运行该应用程序:

I think, initially at least, you have to install Xcode in order to build a vapor application, just to get the Swift stuff. Having done that, use terminal to change into the vapor project directory and then build and run the application using:

vapor update
vapor build
vapor run

这将导致可执行文件被创建并运行.实际位置取决于您是为调试还是为生产而编译(在Config中设置).假设您仍处于调试阶段,则可以通过键入以下内容直接运行已编译的可执行文件:

This will result in an executable being created and run. The actual location depends whether you are compiling for debug or production (set in Config). Assuming you are still at the debug stage, the compiled executable can be run directly by typing:

.build/debug/Run

从蒸气项目的主目录而不是vapor run.它不会从其他地方运行,因为它使用了Config等的相对路径.

from your vapor project's home directory, instead of vapor run. It won't run from elsewhere because it uses relative paths to Config, etc.

然后您可以将项目树和可执行文件复制到另一台Mac,然后尝试安装Swift运行时库等,以使其在没有Xcode等的情况下运行.

You could then copy the project tree and executable to another Mac and try installing the Swift runtime libraries, etc. to have it running without Xcode, etc.