Vapor 不适用于 xcode 9 和 swift 4 [英] Vapor doesn't work with xcode 9 and swift 4

查看:40
本文介绍了Vapor 不适用于 xcode 9 和 swift 4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试使用 Xcode 9 编译我新创建的蒸汽项目时,我收到 189 个编译错误.完成这项工作的诀窍是什么?我安装了蒸汽和工具箱,并通过蒸汽新测试 --template=api"创建,然后通过蒸汽 xcode"来启动它.

解决方案

Xcode 12/Swift 5.3 更新

vapor 现在是 homebrew/core 的一部分.来源:github

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.

解决方案

Xcode 12 / Swift 5.3 Update

vapor is now part of homebrew/core. Source: github homebrew-core/Formula/vapor.rb.

##### If applicable, remove the obsolete 'vapor/tap' #####
## List current taps:
brew tap
# homebrew/core
# vapor/tap
## Remove tap:
brew untap vapor/tap

#### Install current version of vapor #####
brew install vapor
brew upgrade vapor

Xcode 9 / Swift 4

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.

这篇关于Vapor 不适用于 xcode 9 和 swift 4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆