Getting Started with Server-Side Swift with Vapor 4

Get started quickly with Server-side Swift using Vapor and build your first Vapor web app! By Tim Condon.

Leave a rating/review
Download materials
Save for later
You are currently viewing page 3 of 3 of this article. Click here to view the first page.

Update your Dependencies

One scenario you may encounter is hitting a bug in Vapor or another dependency you use. Make sure you are on the latest package version of any dependencies to see if the update fixes the issue. In Xcode, choose File ▸ Swift Packages ▸ Update to Latest Package Versions. If you’re running the app in Terminal, or on Linux, type:

swift package update

This SwiftPM command pulls down any updates to your dependencies and use the latest releases you support in Package.swift. Note that while packages are in the beta or release candidate stages, there may be breaking changes between updates.

Clean and Rebuild

If you are still having issues, you can use the software equivalent of “turn it off and on again”. In Xcode, use Command-Option-Shift-K to clean the build folder.

You may also need to clear your derived data for the Xcode project as well and the workspace itself. The “nuclear” option involves:

  • Remove the .build directory to remove any build artifacts.
  • Remove your .swiftpm directory to delete the Xcode workspace and any misconfigurations.
  • Remove Package.resolved to ensure you get the latest dependencies next time you build.
  • Remove DerivedData to clear build artifacts cached by Xcode.

Vapor Discord

The steps above usually fix most issues you might encounter that aren’t caused by your code. If all else fails, head to Vapor’s Discord server. You’ll find thousands of developers discussing Vapor, its changes and helping people with issues.

Click the Join Chat button on Vapor’s web site:

Where to Go From Here?

You can download the completed project for this tutorial using the “Download Materials” button at the top or bottom of this page.

This tutorial provided an overview of how to get started with Vapor and how to create basic routes. If you enjoyed this tutorial, why not check out our full-length book on Vapor development: Server Side Swift with Vapor?

If you’re a beginner to web development, but have worked with Swift for some time, you’ll find it’s easy to create robust, fully-featured web apps and web APIs with Vapor.

Whether you’re looking to create a backend for your iOS app, or want to create fully-featured web apps, Vapor is the perfect platform for you.

Questions or comments on this tutorial? Leave them in the comments below!