Can I install xcode in ubuntu?

MahajanSagar picture MahajanSagar · Mar 30, 2016 · Viewed 67.6k times · Source

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

Answer

Anatoli P picture Anatoli P · Mar 31, 2016

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.