Compiling Vapor as Standalone App on MacOS

眉间皱痕 提交于 2020-05-25 20:32:17

问题


I would like to compile Vapor with my code as a MacOS app so I can place it on internal server (drag and click to launch it). I would prefer not to have to install Xcode, swift and other development files on the server. I am new to vapor and swift. I have things running when I build it from xCode. Someone else asked if they could embed it in app, there was yes and no response. The yes did not provide any direction as to how to do it. Can it be compiled to a standalone OSX App? What do I need to do to make it happen? Point me to docs if you know of any. I have compiled apps that are standalone. Just don't know how to do Vapor. Thanks


回答1:


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

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

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.

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.




回答2:


Vapor is a web framework, you don't use it like a macOS app, but you need to deploy on your server together with a web server like Nginx.

https://medium.com/@ahmedraad/how-to-deploy-vapor-app-on-ubuntu-16-04-and-run-it-in-production-eef18f7b4f05



来源:https://stackoverflow.com/questions/48725561/compiling-vapor-as-standalone-app-on-macos

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!