Is it possible to create a application package (directory {ApplicationName}.app) using the Swift package manager in the linux version of the Swift? With GNUStep, adding a GNUmakefile file to my project, I can do that (and for what I read, I could run this application on a macOS machine? Or am I wrong?). How to do that with Swift and the SPM? After execute swift build, I can see that the binaries are located on directory like .build/x86_64-unknown-linux-gnu/debig (or .build/x86_64-unknown-linux-gnu/release, if I use swift build -c release). How I build the application package with the files located here?
Related
I do not have any familiarity with the Swift Package Manager, but I have to compile a Swift program (https://github.com/ltentrup/SafetySynth, if it matters) as a statically linked executable (on Linux).
First of all. Is it possible?
The project uses the Swift Package Manager to build the executable, through the swift build command.
Is there any command line flags to tell the SPM to make a static executable?
This question specifically concerns the Swift Package Manager, because I'm on Linux, so I'm not using Xcode (and the project does not use Xcode neither).
I'm writing my Swift app for Ubuntu using Vapor. And my mission is to have the smallest Docker image for production. I've trimmed down my image significantly but I wanted to know, just out of curiosity, does my final executable need all the compiled .module, .doc and .build files in the same directory?
tl;dr: No.
The folders/files you listed are byproducts of the build process and can be safely discarded.
When it comes to distribution, your application is just like any other Linux executable. You must have all dynamically linked libraries available on the target system.
These include the runtime libraries of the Swift toolchain plus any compiled C modules your application (or the framework beneath it) links with (*).
You can check the dependencies of the executable using the ldd command.
Some of them are available as packages, some of them will need to be copied to the target system manually.
(*) In case of a Vapor 2 application, such C modules are libCHTTP.so and libCSQLite.so, which are placed in your build folder.
I would like to prepare the environment for working with Swift on Ubuntu 16.04.
I installed Swift and Atom editor.
I installed the Script package, which allows me to run code from the Atom editor.
Generally it is nice when I compile and run one file (Ctrl+Shift+B shortcut).
The problem is when I would like to build a project composed of several files.
Classes defined in the other files (not the one I compile) are not visible (compilation error).
Is it possible to configure the editor to compile and run the entire project?
How to import external library, eg ObjectMapper ?
You can use the Atom package build. It allows you to create custom build commands and such by using common build providers. You can build with a Makefile or JSON or CSON or YAML or even Javascript. It provides enough flexibility that you can build just about anything. Just make your build file so that it points to all the files to build with the right compiler (probably swiftc in your case). With a Javascript build file, you can even specify a command to run before and after the build, say, to run your newly built program.
There's a great open source project I have been watching called Marathon. It's a package manager and they have been Working on a deployment on linux. I'm not sure how much success they have had, but you can follow along here and maybe help out.
https://github.com/JohnSundell/Marathon/issues/37
Edit: It looks like it does work on linux!
git clone https://github.com/JohnSundell/Marathon.git
$ cd Marathon
$ swift build -c release
$ cp -f .build/release/Marathon /usr/local/bin/marathon
For dependencies, you should use Swift Package Manager.
You can check how Vapor is built - it is prepared for build apps for Ubuntu too.
Also, Vapor toolbox would help you with other projects
https://docs.vapor.codes/2.0/getting-started/install-on-ubuntu/
You can build a Swift project using VS Code + Swift Development Environment extension
If steps on the link above are not clear enough, I've put more details in a blog post
After building a package how do you install it on the system?
For example, I'm trying to install Swift language server but I have no idea what to do after swift build. Do I have to copy executables and libraries manually?
In CMake/make world there is always a make install step. Is there anything similar in Swift package manager? There doesn't seem to be an install command or something similar. Am I missing something?
Swift Package Manager produces plain executables, in .build/debug or .build/release directory. You can see the last line in its output Linking .build/debug/<the name of the main module in the Package>.
If not specified otherwise, you can just run the result executable, as any other executable, by typing its path in the command line and providing parameters as needed.
Swift Package Manager does not support custom scripts or targets, like install, deploy etc. If there is a need for installation/deployment automation, it should be done by additional scripts or tools, like Makefile.
I would like to use install4j to make it easier to deploy my Java application to Windows, Mac, and Linux. I am evaluating install4j on my Windows development machine to make sure it can do what I need before I purchase it.
So far, I can get it to work for Windows and Linux but not for the Mac. The Mac app bundle that I cobbled together (without install4j) currently has the following structure where the Java dir contains external jar files (such as derby.jar) required by my application.
myApp.app
Contents
MacOS
Resources
Java
Perhaps I can use a simpler structure but this is what I have for now and it works. Unfortunately, the structure install4j builds does not work (it cannot find my derby.jar) and I cannot figure out how to get install4j to duplicate the app bundle directory structure that I know does work.
Any suggestions?