image.png
Perfect is a complete and powerful toolbox, framework and application server for Linux, iOS and MacOS (OS X). It provides everything that Swift engineers need to develop lightweight, maintainable, and extensible applications and other REST services for the Swift programming language for client and server-side applications.
In the next few articles I will record the Perfect framework. Those interested can see:
Swift Perfect-Ubuntu server deploymentSwift Perfect-Qiniu upload files[Swift Perfect-iOS Message Push (APNs) to obtain APNs authorization code] (https://www.jianshu.com/p/3058d80761e8)Swift Perfect-Use the systemd command server project to run in the backgroundInstallation and deployment of Nginx in Ubuntu environmentSwift Perfect-Nginx configure HTTPS server
The following is what I wrote using Perfect (If there is anything that can help you, I hope I can like it, and by the way, I like it on GitHub)
Github:https://github.com/LeeCenY/iRent
Development Environment | Version |
---|---|
Swift | 3.0.2 |
Perfect | 2.0 |
Ubuntu | 16.04 |
Use https://github.com/PerfectlySoft/Perfect-Ubuntu to deploy Swift and Perfect
apt-get update
sudo apt-get install clang libicu-dev
image.png
Import PGP key (two methods)
method one:
gpg --keyserver hkp://pool.sks-keyservers.net \
- - recv-keys \
'7463 A81A 4B2E EA1B 551F FBCF D441 C977 412B 37AD' \
'1 BE1 E29A 084C B305 F397 D62A 9F59 7F4D 21A5 6D5F' \
' A3BA FD35 56A5 9079 C068 94BD 63BC 1CFE 91D3 06C6'
wget -q -O - https://swift.org/keys/all-keys.asc | \
gpg --import-
tar xzf swift-3.0.2-RELEASE-ubuntu16.04.tar.gz
mv swift-3.0.2-RELEASE-ubuntu16.04 swift
echo "export PATH=/root/swift/usr/bin:"${PATH}"" >> ~/.bashrc
source ~/.bashrc
swift --version
command to check whether the Swift environment is set successfullySwift version 3.0.2 (swift-3.0.2-RELEASE)
Target: x86_64-unknown-linux-gnu
sudo apt-get install git
sudo apt-get install openssl libssl-dev uuid-dev
git clone https://github.com/PerfectlySoft/PerfectTemplate.git
cd PerfectTemplate
swift build
. build/debug/PerfectTemplate
[ INFO] Starting HTTP server localhost on 0.0.0.0:8181
ln -s /usr/include/libmongoc-1.0/ libmongoc-1.0
or
ln -s /usr/include/libmongoc-1.0/usr/local/include/libmongoc-1.0
swift build
. This is the case with my following two dependencies. Package(url:"https://github.com/SwiftORM/MongoDB-Storm.git", majorVersion:1),.Package(url:"https://github.com/PerfectlySoft/Perfect-RequestLogger.git", majorVersion:1),
Update dependencies:
swift package update
swift build
swift package update update dependencies
swift build builds a quick package
swift build -c release build a quick release code
swift package generate-xcodeproj Create or update Xcode project from Swift code
swift package resolve to get all dependencies
image.png
image.png
There are many pitfalls in Ubuntu deployment, almost "from getting started to giving up". In the end, I accidentally saw Perfect-Ubuntu in Slack, and I wanted to try again. Getting started with Vapor..." (Vapor was successfully deployed, with few pits), and finally this Perfect-Ubuntu solved the database problem and deployed successfully!
Study materials:
Perfect official websiteSwift/Perfect deployed on UbuntuPerfect network framework application-basic method, MySQL connection and Cpp code accessbased on Perfect Swift server developmentFull stack Swifter: First, the perfect framework