Swift is to iOS what Java is to Android.
Swift is a general-purpose, multi-paradigm, compiled programming language developed by Apple Inc. and the open source community (version 2.2 only).
First released in 2014, Swift was developed as a replacement for Apple's previous programming language, Objective-C, as Objective-C had remained largely unchanged since the early 1980s and lacked modern language features.
Development of Swift began in July 2010 by Chris Lattner (same creator of LLVM and clang), with the eventual collaboration of many other Apple programmers. Swift was based on ideas from languages such as: Objective-C, Rust, Haskell, Ruby, Python, C#, CLU and many others.
Swift is to iOS what Java is to Android. The compiler is written in C++.
Installation
This entire procedure works as of Ubuntu 20.04, but it was actually tested on Ubuntu 21.04 . But I was also able to install it with this procedure on Gentoo (just changing the package name to Portage) and it worked, that is, with small changes you can try it on your operating system or Linux distribution.
  1. Before anything else, install the dependencies: sudo apt install binutils git gnupg2 libc6-dev libcurl4 libedit2 libgcc-9-dev
  2. Import the PGP key gpg --keyserver hkp://keyserver.ubuntu.com
    --recv-keys
    '7463 A81A 4B2E EA1B 551F FBCF D441 C977 412B 37AD'
    '1BE1 E29A 084C B305 F397 D62A 9F59 7F4D 21A5 6D5F'
    'A3BA FD35 56A5 9079 C068 94BD 63BC 1CFE 91D3 06C6'
    '5E4D F843 FB06 5D7F 7E24 FBA2 EF54 30F0 71E1 B235'
    '8513 444E 2DA3 6B7C 1659 AF4D 7638 F1FB 2B2B 08C4'
    'A62A E125 BBBF BB96 A6E0 42EC 925C C1CC ED3D 1561'
    '8A74 9566 2C3C D4AE 18D9 5637 FAF6 989E 1BC1 6FEA'
    'E813 C892 820A 6FA1 3755 B268 F167 DF1A CF9C E069'
  3. Extract the file tar zxvf swift-*
  4. Remove the compressed file rm swift-*.tar.gz
  5. Change the directory name to swift only mv swift-5.5.2-RELEASE-ubuntu20.04/ swift
  6. Move it to optional directory sudo mv swift/ /opt/
  7. Include the location in your $PATH echo 'export PATH=/opt/swift/usr/bin:"${PATH}"' >> ~/.bashrc
  8. Make it possible to access it immediately source ~/.bashrc exec $SHELL
  9. Check if everything is ok swift -version
  10. Test one Hello, World! vim hello.swift
print("Hello, World!")
Runtime Testing: swift hello.swift
Or compile your code and run the binary: swiftc hello.swift ./hello