I have Ubuntu in my virtual machine, i want to run X code in Ubuntu.I just download swift from site but don't know how to install it in Ubuntu. https://swift.org/builds/swift-2.2-release/ubuntu1404/swift-2.2-RELEASE/swift-2.2-RELEASE-ubuntu14.04.tar.gz
-
5Answer is NO. XCode is not available in Ubuntu – Deepak Thakur Mar 30 '16 at 08:20
-
4You can install xcode on virtualbox. – K.Sopheak Mar 03 '17 at 05:00
-
3Possible duplicate of [Can you Run Xcode in Linux?](https://stackoverflow.com/questions/2406151/can-you-run-xcode-in-linux) – Innat Mar 17 '19 at 22:40
1 Answers
If you want to install Xcode in Ubuntu, that is impossible, as already pointed out by Deepak: Xcode is not available on Linux at this time and I don't expected it to be in the foreseeable future.
However, if you want to install Swift on Ubuntu and play with it from the command line, that is quite easy to do. The instructions are at the http://www.swift.org site, but here is a brief recap, assuming you are in your home directory:
1) Download the distribution:
user@ubuntu14:~$ wget https://swift.org/builds/swift-2.2-release/ubuntu1404/swift-2.2-RELEASE/swift-2.2-RELEASE-ubuntu14.04.tar.gz
2) Unpack it:
user@ubuntu14:~$ tar xf swift-2.2-RELEASE-ubuntu14.04.tar.gz
3) Prepend the location of the binaries to your $PATH
:
user@ubuntu14:~$ export PATH=$HOME/swift-2.2-RELEASE-ubuntu14.04/usr/bin:$PATH
That's it as far as installation. Now you can do a few things with it, these are just examples.
Run the REPL:
user@ubuntu14:~$ swift
Welcome to Swift version 2.2 (swift-2.2-RELEASE). Type :help for assistance.
1> 1 + 3
$R0: Int = 4
2> :quit
user@ubuntu14:~$
Create a Swift source file, call it junk.swift
, with the following contents:
print("Hi from swift!")
Then run it through the Swift interpreter:
user@ubuntu14:~$ swift junk.swift
Hi from swift!
Now compile it with the Swift compiler:
user@ubuntu14:~$ swiftc junk.swift
This will create an executable called junk
in your current directory. Run it:
user@ubuntu14:~$ ./junk
Hi from swift!
You can do a lot more, please see documentation at https://swift.org/getting-started/#using-the-build-system
Please make sure your Ubuntu installation is 64-bit. If it is, then the string x86_64
should be found somewhere in the output of the uname -a
command. AFAIK, currently Apple provides this software only for 64-bit Ubuntu 14.04 or Ubuntu 15.10, make sure you download the correct version.
Another thing to note is that Swift on Linux is not as usable as it is on Mac OS X. A lot of libraries have not been ported yet. Again, see the swift.org site for more details.

- 4,791
- 1
- 18
- 22
-
This is also a more detailed steps to install both swift and vapor https://www.digitalocean.com/community/tutorials/how-to-install-swift-and-vapor-on-ubuntu-16-04 – Salma Gomaa Sep 08 '19 at 13:01
-
-
@JoãoPimentelFerreira Swift is a programming language instead XCode is an IDE for coding in Swift – Lorenzo Morelli Apr 25 '21 at 10:08