jhamPac jhamPac - 2 years ago 173
Swift Question

How to build Swift Perfect Server using Xcode for Ubuntu?

So I understand how we can build it for OSX but how do we build perfect server http on Linux? Is there a way we can build the source code using Xcode but have it compile for Ubuntu?

Answer Source

You cannot build in Xcode for Linux, however you can just develop in xCode and then build sources on Ubuntu. In release-1.0 brunch both PerfectLib and PerfectServer contain makefiles. Take a look on description in these links. PerfectLib-1.0, PerfectServer-1.0

However during the development you will need to modify the makefiles in order to properly build it on linux. This might be time-consuming in some cases if you don't have that much experience with them.

As alternative to it, you can pull from Master branch which at this moment (April 25, 2016) is build against Swift 3.0 March 24 Snapshot. With not much effort you can setup all your dependencies to have PerfectServer and handlers to build with Swift Package Manager in single make command.

Update: Building Perfect Server on Ubuntu (April 28, 2016)

We first need to install the set of dependencies.

sudo apt-get install libssl-dev libevent-dev libsqlite3-dev libcurl4-openssl-dev libicu-dev uuid-dev

PerfectLib at this moment (Apr 28, 2016) builds against Swift 3.0 March 25 and April 12th snapshots. Since there are few fundamental changes in these releases there is different PerfectLib release for each.

If Swift 3.0 toolchain is not installed on your ubuntu, download, extract and export it into path:

wget https://swift.org/builds/development/ubuntu1510/swift-DEVELOPMENT-SNAPSHOT-2016-04-12-a/swift-DEVELOPMENT-SNAPSHOT-2016-04-12-a-ubuntu15.10.tar.gz  
tar xvf swift-DEVELOPMENT-SNAPSHOT-2016-04-12-a-ubuntu15.10.tar.gz  
export PATH=/your/full/path/to/swift-DEVELOPMENT-SNAPSHOT-2016-04-12-a-ubuntu15.10/usr/bin/:"${PATH}"  

You won't be able to build Perfect out of the box from master branch, so I have made modifications to it so that the build process can be simplified to single make. Depending on your Swift 3.0 Snapshot do the following:

For March 25 Snapshot:

git clone https://github.com/ambientlight/PerfectServer.git

For April 12 Snapshot:

git clone -b swift.3.0-april https://github.com/ambientlight/PerfectServer.git

And let's build it:

cd PerfectServer/
cp .build/debug/perfectserver* ./

And finally you can launch either perfectserverhttp or perfectserverfcgi server variaton:

sudo ./perfectserverhttp
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download