Vapor doesn't work with xcode 9 and swift 4

别等时光非礼了梦想. 提交于 2019-12-09 14:09:09

问题


When I try to compiled my newly created vapor project with Xcode 9 I get 189 compile errors. What's the trick to making this work? I installed vapor and the toolbox, and create via 'vapor new test --template=api' and then 'vapor xcode' to start it up.


回答1:


Check that everything is up to date. The following builds and runs for me at this time:

Use latest vapor toolbox.

Currently:

vapor new test --template=api
cd test
swift package tools-version
# 4.0.0
# use `swift package tools-version --set-current` if needed
rm Package.resolved
vapor update
vapor --version
# Vapor Toolbox: 3.1.2
# Vapor Framework: 2.3.0

Note, Vapor Framework:__ only shows when the terminal working directory pwd is pointing to a vapor project directory.

If needed ...

brew tap --full  vapor/homebrew-tap
brew update 
brew upgrade

In some cases the vapor toolbox may need to be deleted and reinstalled. (see "vapor toolbox broken after upgrading swift")

Use latest Xcode release.

Currently: Xcode: 9.1, Swift: 4.0.2

swift --version
# Apple Swift version 4.0.2 (swiftlang-900.0.69.2 clang-900.0.38)

Use vapor update or swift package update

vapor new test --template=api
cd test
rm Package.resolved
vapor update

alternately,

vapor new test --template=api
cd test
rm Package.resolved
swift package update
swift package generate-xcodeproj

The above updates, compiles and runs OK for me in Xcode 9.1.

Note: However, there are about 44 new deprecation warnings of the same type. I first became aware of the characters deprecation with Xcode9.1/Swift4.0.2.

'characters' is deprecated: Please use String or Substring directly"

So, new deprecation warnings, but 0 errors ... and, more importantly, the project runs as Vapor 2 + Swift 4.

Also, check Packages.resolved versions versus what is available in each respective source repository. On github, the Vapor Examples Lab: TemplateApiTest repository contains the Packages.resolved which was generated and works with the tool chain scenario above.

Finally, double check that the target is Run on macOS and not an ARM-based iOS for this build.




回答2:


Try 'brew upgrade vapor', if using brew. If you're using apt, try "sudo apt-get update" and then "sudo apt-get install vapor". This worked for me. I think because I had installed 2.0 a while ago, which couldn't sink with 3.0 projects.



来源:https://stackoverflow.com/questions/47104737/vapor-doesnt-work-with-xcode-9-and-swift-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!