233

Can you run Xcode in Linux? Mac OS X was based on BSD Unix, so is it possible?

From what I have heard, there is a MonoDevelop plugin that has an iPhone simulator.

Eric Leschinski
  • 146,994
  • 96
  • 417
  • 335
Mohit Deshpande
  • 53,877
  • 76
  • 193
  • 251
  • 3
    I think this is what you're looking for Apple released swift to replace xcode for linux ios devs http://www.cnet.com/news/apple-introduces-swift-2/ – PauAI Jun 10 '15 at 23:49
  • 1
    They released swift not Xcode. – Antzi Jun 10 '15 at 23:51
  • Still not good. It's just that the language is open source and published on Linux together with a standard library. It is not intended to make iOS apps or replace Xcode. More like to make Linux apps with swift. Of course this would simplify the job of people wanting to make a cross compiler. – Antzi Jun 10 '15 at 23:54

16 Answers16

485

The low-level toolchain for Xcode (the gcc compiler family, the gdb debugger, etc.) is all open source and common to Unix and Linux platforms. But the IDE--the editor, project management, indexing, navigation, build system, graphical debugger, visual data modeling, SCM system, refactoring, project snapshots, etc.--is a Mac OS X Cocoa application, and is not portable.

cdespinosa
  • 20,661
  • 6
  • 33
  • 39
  • 98
    +1 excellent short breakdown of what is common and what is mac centric – curtisk Mar 09 '10 at 13:04
  • 15
    Not to mention that running it on another OS probably breaks its EULA. Apple is particularly stingy when it comes to license agreements. – jpaugh Aug 06 '15 at 03:30
  • 3
    This is not 100% correct (or up to date). Standard GCC cannot produce Mach-O object files, but Clang can. But then you still need Apple's ld to link the final binary. Darling can run the original Xcode toolchain on Linux (but not Xcode IDE). – LubosD Feb 18 '16 at 13:06
  • 1
    why is a Cocoa application not portable? – altruios Jul 23 '22 at 16:09
50

Nobody suggested Vagrant yet, so here it is, Vagrant box for OSX

vagrant init AndrewDryga/vagrant-box-osx --box-version 0.2.1
vagrant up
# editor's notes:
# - this requires virtualbox
# - version 0.3.1 (2016) is down now, so version 0.2.1 (2015)
# - there are notes for building an image one's self at the site

and you have a MACOS virtual machine. But according to Apple's EULA, you still need to run it on MacOS hardware :D But anywhere, here's one to all of you geeks who wiped MacOS and installed Ubuntu :D

Unfortunately, you can't run the editors from inside using SSH X-forwarding option.

fuzzyTew
  • 3,511
  • 29
  • 24
bbozo
  • 7,075
  • 3
  • 30
  • 56
  • 5
    Do you need to be able to run the GUI editors in order to build apps with Xcode or can it be done from the CLI? – Jose V Mar 13 '18 at 07:02
  • 1
    Seems that URL is dead now, does anyone have an updated link? – bdotsamir Jan 29 '22 at 16:40
  • This one seems more up-to-date: https://app.vagrantup.com/amarcireau/boxes/macos you can search that website to find more. – fuzzyTew Dec 03 '22 at 00:06
32

I really wanted to comment, not answer. But just to be precise, OSX is not based on BSD, it is an evolution of NeXTStep. The NeXTStep OS utilizes the Mach kernel developed by CMU. It was originally designed as a MicroKernel, but due to performance constraints, they eventually decided they needed to include the Unix portion of the API into the kernel itself and so a BSD-compatible "server" (originally intended to process requests for BSD-compatible kernel messages) was moved into the kernel, making it a Monolithic kernel. It may be BSD compatible in the programming API, but it is NOT BSD.

The rest of the OS involved ObjectiveC (under arrangements between Stepstone and Richard Stallman of GNU/GCC) with a GUI based on a technology called "Display Postscript" ... sort of like an X Server, but with postscript commands. OS X changed Display Postscript to Display PDF, and increased the general hardware requirements 1000 fold (NeXT could run in 8-16MB, now you need GB).

Due to the close marriage of GCC and Objective C and NeXT, your best bet at running XCode natively under Linux would be to do a port (if you can get ahold of the source - good luck) utilizing the GNUStep libraries. Originally designed for NextStep and then OpenStep compatibility, I've heard they are now more-or-less Cocoa compatible, but I've not played with any of it in almost 2 decades. Of course that only gets you as far as ObjC, not Swift, and I don't know if Apple is going to OpenSource it.

Evan Langlois
  • 4,050
  • 2
  • 20
  • 18
19

You can run Xcode on Linux NATIVELY using Darling:

Darling is a translation layer that lets you run macOS software on Linux

Once installed you can install Xcode via command-line developer tool following this link.

halfer
  • 19,824
  • 17
  • 99
  • 186
Francesco Iapicca
  • 2,618
  • 5
  • 40
  • 85
  • 1
    In theory, yes. In practice.. not so much. The installation is super painful and Darling itself just isn't stable enough for serious use, sadly.. – Firzen May 23 '23 at 08:39
10

If you run VMware Player or Workstation (or maybe VirtualBox, I'm not sure if it supports Mac OS X, but may), and then Mac OS X Server (Client can't legally be virtualized). Of course, in this case you are running XCode on OS X, but your host machine could be linux.

Ian
  • 101
  • 2
  • 6
    It is indeed possible to run OS X inside VirtualBox. I run 10.8 Mountain Lion this way. You must follow a howto. It works almost flawlessly. I am danish, so I had to build my own keybord layout. – Kristian Spangsege Oct 15 '12 at 10:43
  • 3
    Even Server can only be (legally) virtualized only on Apple Hardware; I think it would be legal however to run Linux on Apple hardware and then Mac OS X as its guest (though I'm not sure this is an attractive option). @KristianSpangsege: glad to hear it runs for you under VirtualBox... I installed about 5 different versions and all were very slow. I thought it was a problem with all virtualized MacOSXs until I switched to VMware... almost no problems there (occasional short slowdown still occurs). – johndodo Jan 03 '14 at 21:34
8

If you cannot shell out thousands of dollars for a decent Mac then there is an option to run OSX and XCode in the cloud:

http://www.macincloud.com/

Roman Kagan
  • 10,440
  • 26
  • 86
  • 126
4

I think you need MonoTouch (not free!) for that plugin.

And no, there is no way to run Xcode on Linux.

Sorry for all the bad news. :)

andyvn22
  • 14,696
  • 1
  • 52
  • 74
3

Nope, you've heard of MonoTouch which is a .NET/mono environment for iPhone development. But you still need a Mac and the official iPhone SDK. And the emulator is the official apple one, this acts as a separate IDE and allows you to not have to code in Objective C, rather you code in c#

It's an interesting project to say the least....

EDIT: apparently, you can distribute on the app store now, early on that was a no go....

curtisk
  • 19,950
  • 4
  • 55
  • 71
2

The easiest option to do that is running a VM with a OSX copy.

Hedron Dantas
  • 616
  • 2
  • 6
  • 16
2

I would suggest KVM. It is going to provide you almost native performance and it is built-in Linux. Go and check it out.

You will feel like you are using Mac only and then install Xcode there you may even choose to directly boot into the OSX GUI instead of Linux one on startup.

halfer
  • 19,824
  • 17
  • 99
  • 186
1

If you really want to use Xcode on linux you could get Virtual Box and install Hackintosh on a VM. Edit: Virtual Box Guest Additions is not supported with MacOS Movaje. You will want to use VMware

https://www.vmware.com/

https://hackintosh.com/

RK_DUDE02
  • 25
  • 5
0

If you want XCode on another OS, I suggest cloud computing. That way your app is being developed on a Mac and can be submitted to the App Store.

Josh Guyette
  • 106
  • 1
  • 4
0

Use quiling framework For more info check at https://github.com/qilingframework/qiling I think it is the best

  • Please provide additional details in your answer. As it's currently written, it's hard to understand your solution. – Community Aug 30 '21 at 07:42
0

Maybe you can use Virtual Machine and Qiling framework.

JerryIce
  • 1
  • 1
0

If you are planning to use a Mac VM on Linux, check out Docker-OSX. It provides a simple approach to use pre-built Mac VMs with Docker.

To know more about the legality of running Apple software on non-Apple hardware, read this article: Is Hackintosh, OSX-KVM, or Docker-OSX legal?

CFV
  • 740
  • 7
  • 26
-3

OSX is based on BSD, not Linux. You cannot run Xcode on a Linux machine.

cdespinosa
  • 20,661
  • 6
  • 33
  • 39
rfunduk
  • 30,053
  • 5
  • 59
  • 54
  • 3
    It has nothing to do with what kernel its running. And MacOS is hardly "based on BSD", see my answer above for the history – Evan Langlois Sep 04 '18 at 16:07