Start Using Vapor 4 (with Swift)

So today I want to share my experience when make Server-Side Project using Vapor with Swift. We will start with a very simple project (“Hello World Project”). This is the first of many articles I will write to discuss using Vapor with Swift. Okay, LET’S START IT!!! YEAY…


Intalling on MacOS

  • Open Terminal
  • We will install the Vapor using HomeBrew. If you don’t have Homebrew, you can download it from https://brew.sh/
brew install vapor/tap/vapor


Make The Project

Still using the Terminal, we will add a new Folder for our project:

mkdir MyFirstProject
cd MyFirstProject

Then let’s use the Vapor’s template for new project

vapor new MyFirstProject

Then there will be a question Would you like to use Fluent? , for now we don’t need it so we can write n there.

You will see like below here:

No alt text provided for this image

It means the progress is finish.

Now you can build it and run it.

cd MyFirstProject
vapor build
vapor run

Then you can try open your browser then open localhost:8080

No alt text provided for this image

You can open the Folder with Finder using open . command on your terminal.

No alt text provided for this image

You can see that it is very different with project that you make with XCode. There’s no xcodeproj file there. You still can open your project with XCode, you can use vapor xcode -y to open it in XCode, or just open any Swift file there.

NOTE: Don’t create the xcodeproj using swift package generate-xcodeproj because the project won’t run properly.

If we see in Project Navigator on XCode, there’s a file called Package.swift and there’s a section called Swift Package Dependencies. We use Swift Package Manager or SwiftPM (it’s similar to Cocoapods in iOS, npm in Node.JS). We use it to download and import every package that we need for our project (vapor is one of the package that imported by SwiftPM)

Okay, we will continue again in the next article. I hope this article can help you start learning about Swift Server-Side using Vapor. Thank you. ??

要查看或添加评论,请登录

David Jourdan Manalu的更多文章

  • Implement MVVM on ReactJS (Using TypeScript)

    Implement MVVM on ReactJS (Using TypeScript)

    MVVM is a design pattern that is very often used by Front-End Engineers. The main idea of this design pattern is to…

  • Write Simple Get Method on Vapor 4 (with Swift)

    Write Simple Get Method on Vapor 4 (with Swift)

    Okay, so this article is the continuation from `Start Using Vapor (with Swift)`. In this article, I will show a simple…

    1 条评论
  • Implement Tree with Swift

    Implement Tree with Swift

    Let’s start it with the definition of tree. What is Tree in programming? Tree is a data structure that contains a…

  • Linked Lists with SWIFT

    Linked Lists with SWIFT

    General Definition for LinkedList What is a linked list? A linked list is a data structure that holds a group of nodes…

社区洞察

其他会员也浏览了