2

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.

Gargoyle
  • 9,590
  • 16
  • 80
  • 145
  • Some examples that have been migrated to Vapor 2 + Swift4 are posted on github [Vapor Examples Lab](https://github.com/VaporExamplesLab). – marc-medley Nov 04 '17 at 18:18

2 Answers2

7

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.

Xcode schema Run > My Mac

marc-medley
  • 8,931
  • 5
  • 60
  • 66
  • I have the same toolbox version, but mine version command doesn't show the framework output. My swift version is the same as yours (note you said vapor instead of swift in that command copy). I still get 193 errors. – Gargoyle Nov 04 '17 at 20:35
  • `swift package tools-version` retuns an error that there's no such file or directory package. – Gargoyle Nov 04 '17 at 22:29
  • OK, everything looks the same as yours. My tools-version says 4.0.0. But I get tons of xcode errors when I open the project – Gargoyle Nov 04 '17 at 22:35
  • Here's an example from Crypto, which is failing. My openssl came from brew. ld: warning: ignoring file /usr/local/opt/openssl/lib/libssl.dylib, file was built for x86_64 which is not the architecture being linked (arm64): /usr/local/opt/openssl/lib/libssl.dylib – Gargoyle Nov 04 '17 at 22:37
1

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.