Broader Frontends
Author : Kazuhiro Hara
Article permalink

Installing Vapor on a MacBook Air M3, and Some Thoughts on Xcode

I had been installing and playing with Vapor on a ThinkPad, but since I bought a MacBook Air, I tried installing it there as well.

Installing Vapor on a ThinkPad, or rather on Windows, is not that difficult if you have already prepared the Swift environment. I think WSL is essential.

With some other web application frameworks, installation did not go well or the runtime behavior did not work properly. From that perspective too, Vapor was excellent. Installing it on a MacBook Air was about ten times easier than installing it on a Windows machine. I think it is fair to say there was almost no friction.

Installing Vapor

If you follow the official documentation, you are basically done, but I will leave a log for later.

First, check the Swift version. Since Xcode is installed, the latest version is naturally available.

$ swift --version

swift-driver version: 1.115 Apple Swift version 6.0 (swiftlang-6.0.0.9.10 clang-1600.0.26.2)
Target: arm64-apple-macosx14.0

Next, install Vapor. I used brew.

$ brew install vapor

...

==> Downloading https://ghcr.io/v2/homebrew/core/vapor/manifests/18.7.5
##################################################################################################################################################### 100.0%
==> Fetching vapor
==> Downloading https://ghcr.io/v2/homebrew/core/vapor/blobs/sha256:5d0e1fa0fe4b21022520634975d94938e6cbb98938d3a0491b28303455c26119
##################################################################################################################################################### 100.0%
==> Pouring vapor--18.7.5.arm64_sonoma.bottle.tar.gz
🍺  /opt/homebrew/Cellar/vapor/18.7.5: 6 files, 7.3MB
==> Running `brew cleanup vapor`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).

That is all for installation. Next, I did a quick check after installation. This makes the vapor command available. Having a CLI is convenient.

$ vapor --help

Usage: vapor <command>

Vapor Toolbox (Server-side Swift web framework)

Commands:
       build Builds an app in the console.
       clean Cleans temporary files.
      heroku Commands for working with Heroku.
         new Generates a new app.
         run Runs an app from the console.
             Equivalent to `swift run App`.
             The --enable-test-discovery flag is automatically set if needed.
  supervisor Commands for working with supervisord.
       xcode Opens an app in Xcode.

Use `vapor <command> [--help,-h]` for more information on a command.

Now create a project. Use the vapor new command. The -n option automatically answers no to the questions.

$ vapor new hello -n

Cloning template...
name: hello
Would you like to use Fluent (ORM)? (--fluent/--no-fluent)
y/n> no
fluent: No
Would you like to use Leaf (templating)? (--leaf/--no-leaf)
y/n> no
leaf: No
Generating project files
+ Package.swift
+ entrypoint.swift
+ configure.swift
+ routes.swift
+ .gitkeep
+ AppTests.swift
+ .gitkeep
+ Dockerfile
+ docker-compose.yml
+ .gitignore
+ .dockerignore
Creating git repository
Adding first commit

Editing the Project

If you open the generated project's Package.swift in Xcode, the necessary dependencies are loaded and it becomes ready to run. At first, I actually thought I would edit it in the familiar VS Code, but in a Mac environment I realized that setting up a Swift editing environment in VS Code is instead more troublesome.

So development with Vapor will be done in Xcode.

Once I started developing in Xcode, I noticed that being able to launch the application by pressing the triangular run button in Xcode when running locally is very nice. In visionOS development, apps can similarly be run from the run button, and being able to run server-side Swift with the same feeling makes the operation seamless and stress-free.

Also, using the Dockerfile and docker-compose.yml generated when creating a new project, you can immediately start a Docker container locally. This is also convenient, so I recommend it.

A Small Announcement

The seventh visionOS study group will be held at Apple Japan on Wednesday, October 23. I am planning to give a lightning talk there, so please join if your schedule allows.

DockerMacSwiftVaporVision Pro

Share