天天看點

ios伺服器管理系統,iOS Perfect部署到伺服器

伺服器系統:Ubuntu Server 16.04.1 LTS 64位

-----------------------搭建Swift環境---------------------------

1.安裝所需的依賴項:

sudo apt-get install clang libicu-dev

2.下載下傳對應ubuntu的版本号和對應的數字簽名

wget https://swift.org/builds/swift-4.2-release/ubuntu1604/swift-4.2-RELEASE/swift-4.2-RELEASE-ubuntu16.04.tar.gz

wget https://swift.org/builds/swift-4.2-release/ubuntu1604/swift-4.2-RELEASE/swift-4.2-RELEASE-ubuntu16.04.tar.gz.sig

3.将PGP密鑰導入密鑰環:

wget -q -O - https://swift.org/keys/all-keys.asc | \

gpg --import -

4.解壓剛才下載下傳的swift

tar xzf swift-4.2-RELEASE-ubuntu16.04.tar.gz

5.進入解壓包的swift-4.2-RELEASE-ubuntu16.04 -> usr -> bin目錄 通過以下指令擷取路徑

pwd

6.通過上一步擷取的路徑設定環境變量

sudo vi /etc/profile

//輸入 i 進入編輯模式

//在最後一行輸入

export PATH=/home/ubuntu/swift-4.2-RELEASE-ubuntu16.04/usr/bin:"${PATH}"

//按ESC退出編輯模式

//輸入:wq 儲存

//重新整理環境變量

source /etc/profile

7.輸入swift --version

// 部署成功顯示如下資訊

Swift version 4.2 (swift-4.2-RELEASE)

Target: x86_64-unknown-linux-gnu

8.可能會出現以下錯誤

// 錯誤

swift: error while loading shared libraries: libatomic.so.1: cannot open shared object file: No such file or directory

//解決方案:輸入以下指令即可

cat /etc/ld.so.conf

echo "/usr/local/lib" >> /etc/ld.so.conf

ldconfig

---------------------------------Perfect-----------------------

1.安裝庫

sudo apt-get install openssl libssl-dev uuid-dev libcurl4-openssl-dev

2.建立Swift軟體包

mkdir MyAwesomeProject

cd MyAwesomeProject

3.用SPM軟體包管理器初始化項目

swift package init --type=executable

這個指令會在目前工作目錄自動生成下列檔案

Creating executable package: MyAwesomeProject

Creating Package.swift

Creating README.html

Creating .gitignore

Creating Sources/

Creating Sources/MyAwesomeProject/main.swift

Creating Tests/

xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

4.然後打開Package.swift檔案進行編輯

import PackageDescription

let package = Package(

name: "LCZProjectDemo",

dependencies: [

.package(url: "https://github.com/PerfectlySoft/Perfect-HTTPServer.git", from: "3.0.0")

// Dependencies declare other packages that this package depends on.

// .package(url: , from: "1.0.0"),

],

targets: [

// Targets are the basic building blocks of a package. A target can define a module or a test suite.

// Targets can depend on other targets in this package, and on products in packages which this package depends on.

.target(

name: "LCZProjectDemo",

dependencies: ["PerfectHTTPServer"]),

.testTarget(

name: "LCZProjectDemoTests",

dependencies: ["LCZProjectDemo"]),

]

)

5.進行編譯和運作

swift build

.build/debug/MyAwesomeProject