Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compiling Vapor as Standalone App on MacOS

Tags:

macos

swift

vapor

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

like image 451
David Avatar asked Feb 10 '18 21:02

David


2 Answers

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.

like image 97
Nick Avatar answered Sep 30 '22 01:09

Nick


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

like image 42
IgnazioC Avatar answered Sep 30 '22 02:09

IgnazioC