Xcode for Windows: How to Build iOS and OSX Apps on Your PC
Do you want to develop software for Mac OS X or iOS? It’s easy to create apps for Linux and Windows on any platform, but developing software for Mac requires a tool set called XCode, designed and built by Apple specifically for Mac OS X.
What is Xcode?
Xcode is an integrated development environment, or IDE, that Apple designed specifically for Mac OS X. An IDE integrates a lot of tools that a developer can use to help them write code, like automatic code completion, version control support, syntax highlighting, debugging, compiling, and more. It puts all these tools in the same interface so all you have to do is click a button for some tasks instead of remembering and then running a command in the terminal.
Xcode has support for many programming languages, including C, C++, Objective-C, Objective-C++, Java, AppleScript, Python, Ruby, ResEdit, and Swift. Both Objective-C and Swift are Apple programming languages, making Xcode the default tool for creating iPhone and Mac OSX desktop apps.
Xcode for Windows?
Xcode is only made for Mac OS X. So if you only have a Windows-based PC, you will have to use some workarounds to run Xcode. And if you want to build iPhone apps or desktop applications for Mac OS X, you may need access to a Mac OS X computer. Fortunately, there are many ways to work around this issue if you have a PC, which we will cover in the upcoming sections.
Rent a Mac in the cloud
A Mac is an expensive piece of hardware. Why buy one if you are only going to use it to develop a Mac OS X or iPhone app? Other people have had this same thought, and modern cloud computing has made it possible to rent a Mac only when you need it. You can even rent a Mac virtual machine by the hour.
Virtual machines make it possible to install operating systems that run in the cloud. Since they are virtual, they can be ready to use in seconds, and when done with them, the virtual machine can be destroyed, with no trace of sensitive data left behind. For years, you could get virtual machines that ran Windows or Linux. Now you can rent Mac OS X virtual machines at places like MacStadium, MacinCloud, and XcodeClub.
While renting a Mac OS X virtual machine by the hour is economical, if you are using it for a specific task like building an app, planning ahead can save you time. If you don’t have an Apple account already, make sure that’s the first thing you sign up for on your virtual machine. If you plan on using Xcode to develop desktop or iPhone apps on your rented Mac, then you will want to check that the software is installed. Xcode is free for the Mac OSX, but it doesn’t come preinstalled. Some cloud providers will pre-install it so you don’t have to spend your time downloading and installing it. More details on installing Xcode are in the next section, Run a Virtual Mac.
Once you rent your Mac, you will sign into it using RDP, which already comes on your Windows installation, or by using a VNC client. You will then enter the IP address of the Mac you rented in either the RDP or VNC client. Once connected to the virtual machine, you will use your username and password to log in. This will take you to the Mac OSX login screen. Here you will use the password again to log in to the desktop.
Run a virtual Mac
Setting up virtual box
You can also create the virtual machine itself and run it locally on your Windows PC. This is surprisingly easy to do with virtualization software like VMWare WorkStation or the open source alternative VirtualBox. You will be doing what Mac cloud providers are doing, but on your own, so you won’t have to pay a rental fee.
For the purpose of this guide, we’ll be using VirtualBox to set up the virtual machine. If you use a different virtual computer application, the process is similar. Since VirtualBox is open source and free to use, it’s worth downloading it if you don’t already have a copy installed.
Running a virtual computer is quite a demanding process, and you’ll need to have a fairly powerful PC for it to operate successfully. You’ll also need a PC with hardware similar to that of a standard, Apple-constructed iMac, MacBook, or Mac Pro.
To successfully emulate a Mac using a Windows PC, you’ll need the following:
- A Dual-Core Intel processor
- At least 2GB of RAM (4GB+ recommended)
- Hardware Virtualization
You’ll also need an installation file for Mac OS X. You can purchase this online from the Apple Store or, if you already own a MacBook, iMac, or Mac Pro, you can use the install disc you received with your computer.
Once you’ve installed VirtualBox, open the application and choose to install Mac OS X Server 64 Bit. Provide the virtual computer with at least 2GB of RAM (If you have more than 8GB of RAM, choose 4GB+.) and more than 30GB of hard disk space.
VirtualBox will automatically configure the operating system, but you’ll still need to make a few changes manually. Open the Settings menu and make the following changes:
- On the System tab, uncheck Enable EFI
- On the Processor tab, select at least two CPUs
- On the Display tab, increase the video memory to at least 128MB
Installing Mac OS X
Now you will need a copy of the Mac OS X operating system. You can get that from the App Store or by borrowing a copy. You may also be able to find virtual disk images that already have the Mac OS X installed. For these, all you have to do is mount the virtual image in Virtual Box, and you will have a virtual Mac running.
If you have the install image for Mac OS X, you will have to go through the installation process. Just mount the virtual installation disk to the virtual machine you created for your new machine in Virtual Box. If the virtual machine is already running, you may have to restart it for it to pick up the installation disk.
Once the virtual installation disk is running on your virtual Mac, you should be able to follow the wizard to install Mac OS X to it. This process may take a few minutes, and you will need to either have or create a new valid Apple ID in order to complete the installation. Once the operating system finishes installing, you can move on to installing Xcode.
Once you’ve configured your Mac OS X virtual machine, installing Xcode is relatively easy. Before you install Xcode, you’ll want to configure your virtual machine to your preferred resolution and settings using the System Preferences menu.
From here, installing Xcode is simple. Open the App Store application from the dock and type “Xcode” into the search bar. You might need to re-enter your account details or enter them for the first time if you didn’t do so during Mac OS X configuration.
Navigate to the Xcode app and click Install Now to download it. If you don’t have an Apple account, you’ll need to create one in order to download the Xcode toolset for your virtual machine.
Xcode is quite a large application, and downloading it could take from a minute to several hours, depending on your Internet connection speed. Once downloaded, open Applications and click “Xcode” to launch the installer.
Upon completion of the installation process, you can use XCode in your virtual machine to program apps for Mac OS or iOS. You can also download other Mac apps to use on your virtual machine.
Build a “Hackintosh”
If you don’t have a Mac, you always have the option of building one. Although we said that Mac OS X and Xcode are only designed to run on Apple hardware, it’s possible to install Mac OS X on a standard PC, though it may take some work.
People that swear by Apple products liked its integration, but Apple is also a closed system. Apple hardware is custom-built for the computer, while much of the hardware running Linux or Windows is interchangeable. Apple software must run on Apple hardware.
Before 2006, Mac computers actually used a different type of processor than the standard PC. Apple had the CPU specifically created for Apple devices. In that environment, it was almost impossible to get Mac OS X to run on a PC, but that didn’t stop the “Hackintosh” community. In 2006, Apple started using an Intel CPU, which makes creating a “Hackintosh” a little simpler. Apple has moved to a custom CPU in their recent hardware releases. But all recent OS X releases can run on an Intel processor, so the steps for turning a standard PC into a machine that can run the Mac operating system should be the same. Another option is creating a dual-boot computer and installing both Windows and Mac OS X on the same machine. When you boot the computer, you will have the option of starting either the Windows or the Mac desktop.
But creating a “Hackintosh” is quite advanced and beyond the scope of this article. That said, converting a standard PC to run Mac may be limited in the future, once Apple’s new CPU becomes the norm. You may have to settle for an older version of Mac OSX that still supports the Intel processor.
Buy a secondhand Mac
If you plan on developing Mac OS X or iPhone apps frequently and if you don’t want to deal with setting up your own virtual machine, logging into your computer on the cloud, or configuring a PC to run Mac OS X, you might want to break down and just buy a Mac.
You can find great deals on old MacBook Pros on sites like eBay. Upon the release of a new generation of MacBooks, Apple fans rush to get the newest model and often put their old machines up for sale. If you buy a MacBook that is only a few years old, it will not only still have some AppleCare left, but also not much of the hardware will have changed. You should be able to update to the latest version of Mac OS X and have a machine you can develop Mac OS X and iPhone apps on for a fraction of the price.
Buy a Mac Mini
Another direction you can take as a Windows user who wants to develop apps for Apple products is buying a Mac Mini. The Mac Mini is a small, portable computer that runs Mac OS X. The Mac Mini also has all the ports you need to connect to hardware like monitors, mice, keyboards, and external hard drives, just like a full-size computer. So you can build a whole computer system around a Mac Mini or use it remotely and connect to it with RDP or VNC from your Windows PC just like you would a virtual machine. It also costs a fraction of what a MacBook Pro or iMac would.
Other options for developing Mac apps
In the options above, we focused on making sure we had a Mac OS X environment to develop on. But you may not need Mac OS X or Xcode to write code that will run on a Mac or on an iPhone. There are other options.
Swift runs on Windows and Linux
In recent years, both Microsoft and Apple have at least partially embraced open source software. One way that Apple did this was by making the Swift programming language open source. So you don’t actually need to be running Mac OS X in order to write code in Swift. Swift now compiles and runs on both Linux and Windows. Swift even supports some of the Windows Desktop GUI. To start developing with Swift on Windows, visit Introducing Swift on Windows.
Create iOS apps using cross platform tools
If the reason you are exploring using Mac OS X and Xcode is iPhone app development, you’re in luck. There are plenty of cross platform frameworks you can use that make it possible to develop iPhone apps on either Mac, Windows, or Linux.
Mobile developers usually either have to specialize in developing iPhone apps or Android apps. The platforms use completely different programming languages, so cross platform tools make it possible to use a single code base to compile apps for both the iOS and Android operating systems.
Use an online Swift sandbox to test your code
If you want to try programming in Swift, Apple’s most popular programming language, you don’t even need a specific type of operating system. You can program online from your phone if you want. Sites like Online Swift Playground and Swift Fiddle will let you write, run, and test your Swift code in the browser.
If you want to develop apps for Mac OS X or the Apple iPhone, you don’t necessarily need a Mac computer. There are quite a few options for Windows users. You can rent a Mac computer through a cloud provider. You can create a Mac virtual machine and run OS X virtually. You can even hack a standard PC so that Mac OS X can run on it. Swift is also cross-platform now, so you can write Swift code on Windows and Linux. And if you are developing phone apps, there are plenty of frameworks available that let you build mobile apps for both Android and iOS on Windows, Mac, or Linux.
Top courses in iOS Development
iOS Development students also learn
Empower your team. Lead the industry.
Get a subscription to a library of online courses and digital learning tools for your organization with Udemy for Business.