HomeNewsInstall SwiftContact
Swift
Install Swift on an AWS Cloud Server
FutureJones
January 15, 2021
1 min

aws

Installing Swift on an AWS server.

AWS now has arm servers available in their Elastic Compute Cloud (EC2).
For details on arm instance types available see -
https://aws.amazon.com/ec2/instance-types/a1/
https://aws.amazon.com/ec2/instance-types/t4/
https://aws.amazon.com/ec2/instance-types/m6/

Step 1 - Deploy and Connect to an AWS ECT Instance.

For details on how to setup, deploy and connect to an AWS EC2 instance please refer to the official documentation.
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EC2_GetStarted.html

In this example we are going to use a t4g.micro instance.

Step 2 - Install Swift

Open a terminal and use SSH to connect to your AWS instance.

ssh -i "********.pem" ******@ec2-*-**-***-**.us-east-2.compute.amazonaws.com

# 1 - add the Swift-Arm repository
## you may need to install tools such as curl git etc.
curl -s https://packagecloud.io/install/repositories/swift-arm/release/script.deb.sh | sudo bash

# 2 - install Swift
## NOTE: The package name for Swift is swiftlang
sudo apt install swiftlang

Step 3 - Testing Swift - Hello World

Create a quick project using the Swift Package Manager to test the Swift installation.

# 1 - create a project directory
~/$ mkdir hello
~/$ cd hello

# 2 - use the swift package manager to initialize the project.
~/hello$ swift package init --type executable
## you should see the following
Creating executable package: hello
Creating Package.swift
Creating README.md
Creating .gitignore
Creating Sources/
Creating Sources/hello/main.swift
Creating Tests/
Creating Tests/LinuxMain.swift
Creating Tests/helloTests/
Creating Tests/helloTests/helloTests.swift
Creating Tests/helloTests/XCTestManifests.swift

# 3 - build the project
~/hello$ swift build
[4/4] Linking hello

# 4 - run the project
~/hello$ swift run
Hello, world!

Swift is now installed and ready to use on your AWS EC2.

Whats Next?

Try some Server-Side Swift with Kitura


Tags

swiftawstutorialserver-side swift

FutureJones

Software Engineer / Project Management

Founder, Engineer, Architect, Manager. Supporting open source software.

Expertise

DevOps
Software Dev
Web Dev

Social Media

linkedintwittergithub

Related Posts

Building Multi-Arch Swift Docker Images
Building Multi-Arch Swift Docker Images
July 10, 2019
1 min
Apple
Powered by MacStadium
February 27, 2021
1 min
Kitura
Kitura Cli App Now Available For Arm
January 29, 2021
1 min
Raspberry Pi
Swift Development on the Raspberry Pi4
January 18, 2021
1 min
News
Swift 5.3.2 Release Now Available
January 12, 2021
1 min
© 2021, All Rights Reserved.

Quick Links

About UsContact Us

Legal Stuff

Social Media