在MacOS上創建一個 hello Vapor 後臺項目
1. 查看當前環境
:~ user$ eval "$(curl -sL check.vapor.sh)"
正常情況
? Xcode 9 is compatible with Vapor 2.
? Xcode 9 is compatible with Vapor 3.
? Swift 4.1 is compatible with Vapor 2.
? Swift 4.1 is compatible with Vapor 3.
碰到的情況
? Xcode 9 is compatible with Vapor 2.
? Xcode 9 is compatible with Vapor 3.
2018-06-08 10:54:13.808 xcodebuild[91618:4860941] [MT] PluginLoading: Required plug-in compatibility UUID 426A087B-D3AA-431A-AFDF-F135EC00DE1C for plug-in at path ‘~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/XAlign.xcplugin‘ not present in DVTPlugInCompatibilityUUIDs
2018-06-08 10:54:13.809 xcodebuild[91618:4860941] [MT] PluginLoading: Required plug-in compatibility UUID 426A087B-D3AA-431A-AFDF-F135EC00DE1C for plug-in at path ‘~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/VVDocumenter-Xcode.xcplugin‘ not present in DVTPlugInCompatibilityUUIDs
? Swift 4.1 is compatible with Vapor 2.
? Swift 4.1 is compatible with Vapor 3.
此處因為Xcode升級導致的插件失效,具體哪個暫時沒有去關註,只找了修正的方法
:~ user$ find ~/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins/ -name Info.plist -maxdepth 3|xargs -I{} defaults write {} DVTPlugInCompatibilityUUIDs -array-add UUID
輸入這條命令即可將uuid註入那個插件的info.plist,然後再按上面的流程查詢就正常了
2. 下載 vapor
:~ user$ brew install vapor/tap/vapor
該命令可能會先 update brew,中間可能會有錯誤,具體情況具體分析
3. 上面完成了之後,切換到自己想要創建項目的文件夾後,敲入以下命令
:自己創建的文件夾 user$ vapor new HelloVapor --api --branch=beta
然後就會開始創建過程,需要一段時間,創建成功後會打印下面的圖案
Cloning Template [Done]
Updating Package Name [Done]
Initializing git repository [Done]
**
**~~**
**~~~~~~**
**~~~~~~~~~~**
**~~~~~~~~~~~~~~**
**~~~~~~~~~~~~~~~~~~**
**~~~~~~~~~~~~~~~~~~~~~~**
**~~~~~~~~~~~~~~~~~~~~~~~~**
**~~~~~~~~~~~~~~~~~~~~~~~~~~**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
**~~~~~~~~~~~~~~~~~~~~~++++~~~**
**~~~~~~~~~~~~~~~~~~~++++~~~**
***~~~~~~~~~~~~~~~++++~~~***
****~~~~~~~~~~++++~~****
*****~~~~~~~~~*****
*************
_ __ ___ ___ ___
\ \ / / /\ | |_) / / \ | |_)
\_\/ /_/--\ |_| \_\_/ |_| \
a web framework for Swift
Project "HelloVapor" has been created.
Type `cd HelloVapor` to enter the project directory.
Use `vapor cloud deploy` to host your project for free!
Enjoy!
4. 接下來關聯xcode
:HelloVapor user$ vapor xcode
打印如下信息
Generating Xcode Project [Done]
Select the `Run` scheme to run.
Open Xcode project?
y/n> y
Opening Xcode project...
上面手動選y,就會用xcode打開工程了,運行的時候只要當前主機的8080端口沒有被占用,則可以正常運行啦
在MacOS上創建一個 hello Vapor 後臺項目