Develop Mac Apps In Javascript

How can you run Xcode on Windows and develop iOS apps with a Windows PC? The short answer is: you can’t! You’ve got a few alternatives to get around that, however. In this tutorial, we’ll discuss how you can install Xcode on Windows to build iOS apps.

Here’s what we’ll get into:

A Mac Build Server, which is a specialized kind of Mac that can be used to compile iOS apps. You’ll create those apps on your Mac, and then instruct the Build Server to compile the app for you. A dedicated Mac is the most convenient, and the most powerful option. A virtual Mac is OK too, but it typically does not perform as well as a physical. Select the products you would like to install – this depends on what platforms you want to make native apps for. If you want to make both Android and iOS apps, then select both Xamarin.Android and Xamarin.iOS. You can also select Mac if you want to develop Mac apps. Then click on Continue.

  • Rent a Mac in the cloud (starting at $20/mo)
  • Run and compile Swift directly on Windows/Linux
  • Learning to code with a Swift Sandbox
  • Build your own “Hackintosh” by installing macOS on a PC
  • Run Xcode on Windows by installing macOS on a virtual machine
  • Develop iOS apps on Windows with cross-platform tools
  • Get your hands on a second-hand Mac (starting at $300)

Let’s get to it!

Xcode for Windows: What & Why

Xcode is the macOS-only software program, called an IDE, that you use to design, develop and publish iOS apps. The Xcode IDE includes Swift, a code editor, Interface Builder, a debugger, documentation, version control, tools to publish your app in the App Store, and much more.

Xcode contains everything you need to build iOS apps, and it only runs on macOS!

That’s when the problems start. You want to make an iOS app with your Windows PC, but you can’t buy a PC or laptop with macOS pre-installed on it. Unlike Windows, Apple doesn’t license its operating system to other computer manufacturers. You can only use macOS on a Mac.

In fact, when you obtain a license to use macOS, which happens when you purchase a Mac computer, you have to agree to only run the operating system on Apple hardware. This effectively limits you to only develop apps on a Mac.

“It’s more fun to be a pirate than to join the navy.”
— Steve Jobs (1983)

But… it’s more fun to be a pirate, than to join the navy, right? Let’s discuss a few alternatives that’ll let you run Xcode on Windows and develop iOS apps on a Windows PC!

Rent a Mac in the Cloud

An even easier way to get your hands on macOS, albeit more expensive, is to rent a Mac “in the Cloud”. You can work with Xcode on Windows with this approach, because you’re essentially connected to a Mac that’s elsewhere.

Here’s how that works:

  • Someone connects a bunch of Mac’s to the internet
  • You sign in on one of those Macs via a Remote Desktop Connection (RDP)
  • Done! You can use this Mac from Windows/Linux and build iOS apps

Services like MacinCloud and MacStadium offer affordable rent-a-Mac products, usually paid on a monthly basis. Prices typically start at $20/month and you can choose from several hardware options, including Mac Mini and Mac Pro.

Starting atType
MacinCloud$20/monthDedicated, Virtual, Server
MacStadium$79/monthDedicated, Enterprise
virtualmacosx.com$9.75/monthShared (timesharing)
Mac Cloud$49/monthVirtual
FlowPremiumDedicated, Enterprise
HostMyApple$25/monthVirtual, Dedicated

You connect to those cloud-based Macs via a Remote Desktop Connection (RDP). Windows includes a stock Remote Desktop Client you can use, and so do most Linux operating systems. Once you’re logged on, you can launch Xcode, and start building your iOS app. That way you’re effectively running Xcode on your Windows PC!

Cloud-based Macs usually come in 3 flavours:

  • A dedicated Mac, which means you get access to a physical Mac located in a data center, as if you bought a Mac in the Apple Store and put it on your desk.
  • A virtual Mac, which means you get access to a virtual Mac in a data center, much like the VirtualBox solution mentioned earlier. Your Mac won’t run on Apple hardware, but it will run macOS.
  • A Mac Build Server, which is a specialized kind of Mac that can be used to compile iOS apps. You’ll create those apps on your Mac, and then instruct the Build Server to compile the app for you.

A dedicated Mac is the most convenient, and the most powerful option. A virtual Mac is OK too, but it typically does not perform as well as a physical Mac computer.

Running Xcode via a Mac in the cloud has a drawback: you can’t easily connect your iPhone to Xcode via USB! With Xcode on your local Mac you can run and debug your app on your own iPhone, via the USB/Lightning cable. This obviously won’t work when your Mac is in the cloud…

Don’t worry! There are plenty of solutions for that:

  • A simple approach is to run your app on iPhone Simulator, right from within Xcode. You can launch iPhone Simulator in Xcode, and debug your app with it. This is perfect for the development phase of your project.
  • An alternative solution are tools like Flexihub, NoMachine and USB Network Gate. They only work with dedicated Mac hardware, and you need to have a dedicated IP address.
  • Install your iOS app on your iPhone via TestFlight, and debug it with a tool like Bugsnag. You can monitor and debug live crashes in your app.

An interesting use case for renting a Mac in the cloud comes from the latest developments in Apple’s hardware. Many designers, developers and desktop-publishers have voiced their concerns over Apple hardware lagging behind, offering low-spec computers for a fairly high price.

If you don’t want to take your $3.000 MacBook Pro with you in a coffee shop, or on your next trip to Thailand, why not purchase a low-end Windows or Linux laptop, and connect to your Mac in the cloud? You can either host it at home yourself, co-locate it in a data center, or rent a dedicated cloud-based Mac.

Do you want to learn how to code iOS apps, but don’t want to invest money in a Mac? Rent a Mac in the cloud for the duration of the iOS development course you’re taking! It’s a great way to bootstrap learning iOS development, and you can always buy your own Mac later.

Learn how to code iOS apps

Get started with Xcode and Swift
Javascript

Ready to get started with iOS development? Learn how to code iOS apps with Xcode and Swift with our immersive iOS development course. Works both on Mac and PC!

Install macOS on Your Windows PC via VirtualBox

The easiest way to run Xcode on Windows is by using a virtual machine (VM).

A virtual machine will create an environment an operating system can run in, as if it’s running on the hardware itself, except it’s running “on top” of your actual hardware and operating system. You can then run Xcode normally, because it essentially runs on macOS on Windows!

This is called virtualization, and it allows you to run Windows on Linux, macOS on Windows, and even Windows on macOS. One of the benefits of virtualization is to run multiple OS side-by-side, which is useful for cross-platform development.

You need 2 things to run macOS on Windows in a VM:

  1. A copy of macOS, as an installer or virtual disk image file
  2. A virtual machine tool, like VirtualBox (free) or VMware (paid)

You can obtain a copy of macOS by downloading it from the App Store or by borrowing it from a friend. A great approach is to search for virtual disk images that have macOS pre-installed. You can also find installers from various sources on the internet, or upgrade a pre-existing image to a newer (beta) version of macOS.

Here’s what you do next:

  1. Install VirtualBox or VMware
  2. Mount the macOS installer or disk image
  3. Start the VM to launch macOS
  4. Launch Xcode!

You can read exactly how to in this tutorial. The recommended system specs are: 4-8 GB of RAM, an Intel i5/i7 compatible CPU, and at least 10 GB of free disk space.

Note: Using macOS on non-Apple hardware is against Apple’s End User License Agreement (EULA). (Fun fact: the same EULA prohibits the use of macOS to manufacture missiles or nuclear weapons…)

Build Your Own “Hackintosh” to Run Xcode

The most obvious choice to run Xcode on a Windows PC is perhaps to literally install macOS on a Windows PC…

“One platform to rule them all” has always been Apple’s take on the world. The Mac, App Store, iOS and Apple Music are all closed systems. Apple enthusiasts have always enjoyed the integrated Apple experience.

On the other hand, the rest of the world builds computers using an “open systems architecture”, in which you can effectively mix-and-match computer components and architectures to create your preferred computing machine.

Building $10.000 gaming PCs, mid-level desktops, blazing-fast ultrabooks, and $250 laptops is only possible because of open hardware. Because of Apple’s closed systems, you’re always bound by the hardware options they give you.

But… what if you want to run macOS on your custom built PC? Apple won’t let you, and your computer manufacturer can’t install macOS for you, even if they wanted to. Because macOS shall only run on Apple hardware!

Enter the “Hackintosh”.

A Hackintosh is a PC that runs macOS. Just like you can install macOS in a virtual machine, or in the cloud, you can install macOS as the bootable operating system on your PC. Switch it on, and macOS loads.

You can also create a dual-boot, i.e. a system that both hosts Windows and macOS. When you boot your PC, you can select the operating system that starts.

Building a Hackintosh can be a tricky exercise, especially if you’re not familiar with PC hardware and creating custom installations. Not all hardware is compatible with macOS. Moreover, Apple has of course created safe-guards against booting macOS on unsupported hardware.

Nevertheless, it’s a good option for running macOS on your custom hardware, and booting macOS on your Windows PC. Check out hackintosh.com for more information, and step-by-step guides.

The name “Hackintosh” comes from the old brand-name of Apple computers: Macintosh, combined with “hack”. Again, it’s against Apple’s EULA – but you wanted to be a pirate, right? Kindle app for pc.

The days of the Hackintosh are almost over, depending on who you ask. Apple’s newer hardware includes a T2 chip now. Hardware-specific chips are notoriously hard to mimic in non-Apple hardware, which essentially means that, in the future, you may not be able to install or update macOS on a computer that doesn’t have that T2 chip.

Swift for Windows & Linux

Developers who want to learn Swift have 2 alternative approaches to code Swift, next to working with Xcode on Windows. Swift is open source, which means you can essentially run it on any system.

Currently, you can use:

OBS (Open Broadcaster Software) is free and open source software for video recording and live streaming. Stream to Twitch, YouTube and many other providers or record your own videos with high quality H264 / AAC encoding. Jun 01, 2020  Open QuickTime Player from your Applications folder, then choose File New Screen Recording from the menu bar. You will then see either the onscreen controls described above or the Screen Recording window described in the following steps.; Before starting your recording, you can click the arrow next to to change the recording settings. To record your voice or other audio with the screen. Mac screen capture. Download Logitech Capture Video Recording & Streaming Software for Mac and PC. (64 bit) DOWNLOAD BETA FOR MAC Download for Windows. VIEW SYSTEM REQUIREMENTS. ALL-IN-ONE CONTENT CREATION. Connect, record, and share. Start recording high-quality video content the second you connect your new webcam. 0:33 Live Stream via XSplit Broadcaster.

  1. Swift 5 on Ubuntu Linux 16.04 and 18.04 via the official images
  2. Swift 4.1 on Windows 10 via the unofficial swiftforwindows.github.io

Here’s how you can run Swift code on Linux:

  1. Download the latest release from swift.org/download
  2. Unzip the .zip in a convenient location
  3. Locate the swift executable in the usr/bin directory
  4. Compile and run a Swift file with swift [filename.swift]

You can also copy the Swift executables to your $PATH, or add Swift’s folder to $PATH, to use the swift command anywhere on your system.

Here’s how you can run Swift code on Windows:

  1. Download the latest release of Swift for Windows from this page
  2. Start the program and point it to your .swift file
  3. Click Run in the program

It appears the Swift for Windows project hasn’t been updated in a while. It’s latest supported version is Swift 4.1., which doesn’t differ that much from Swift 5 in terms of beginner syntax and functionality. Your mileage may vary, though!

You can even run and compile Swift on the $35 Raspberry Pi single-board computer! You can download Swift 5, which has been ported to the ARM CPU architecture, right here. Installing is as easy as pointing your RPi to the swift-arm repo, then do sudo apt-get install swift5, and then run the Swift CLI with swift [filename.swift]. Neat!

Develop iOS Apps on Windows With Cross-Platform Tools

Cross-platform tools are awesome: you code your app once, and export it to iOS and Android. That could potentially cut your app development time and cost in half. Several cross-platform tools allow you to develop iOS apps on a Windows PC, or allow you to compile the app if there’s a Mac in your local network.

Well, not so fast…

The cross-platform tool ecosystem is very large. On the one side you have complete Integrated Development Environments (IDEs) like Xamarin, that allow you to build cross-platform apps with C#.

The middle ground is covered by tools like PhoneGap, Cordova, Ionic and Appcelerator, that let you build native apps with HTML5 components. The far end includes smaller platforms like React Native that allow you to write native apps with a JavaScript wrapper.

The one thing that stands out for all cross-platform tools is this: they’re not beginner friendly! It’s much easier to get access to a Mac, learn Swift, and build a simple app, than it is to get started with Xamarin.

Most of the cross-platform tools require you to have a basic understanding of programming, compilation options, and the iOS and Android ecosystems. That’s something you don’t really have as a beginner developer!

Having said that, let’s look at a couple of options:

  • If you’re familiar with Windows-based development tools and IDEs, and if you already know how to code, it’s worthwhile to check out Xamarin. With Xamarin you code apps in C#, for multiple platforms, using the Mono and MonoTouch frameworks.
  • If you’re familiar with web-based development, check out PhoneGap or Ionic. You’ll feel right at home with HTML 5, CSS and JavaScript. Don’t forget: a native app works different than a website…
  • If you’re familiar with JavaScript, or if you’d rather learn to code JavaScript than Swift, check out React Native. With React Native you can code native apps for iOS and Android using a “wrapper”.

Choose deliberately for a cross-platform tool because it fits your project, not because you think a native platform language is bad. The fact that one option isn’t right, doesn’t immediately make another option better!

If you don’t want to join the proprietary closed Apple universe, don’t forget that many cross-platform tools are operated by equally monopolistic companies like Google, Facebook, Microsoft, Adobe and Amazon.

An often heard argument against cross-platform tools is that they offer limited access to and support for smartphone hardware, and are less “snappy” than their native counterparts. Also, any cross-platform tool will require you to write platform-specific code at one point, especially if you want to code custom features.

Note: You’ll still need to compile your app with Xcode, even if you use cross-platform tools. Most cross-platform tools rely on the command-line tools that are shipped with Xcode, as part of macOS. You’ll also need Xcode to publish your app in the App Store.

Get a Second-Hand Mac

Javascript Get Mac Address

You gotta ask yourself: Why not get a Mac? Perhaps the simplest option to build iOS apps with Xcode, in this tutorial, is purchasing a Mac for iOS development.

If you don’t want to tinker with cross-platform tools, or rent-a-Mac in the cloud, and just want to get started with iOS development: get a Mac.

A simple search on Ebay shows you 1-3 year old second-hand Mac Mini’s for as little as $250. Any newer, decent second-hand Mac Mini will set you back around $450. Don’t forget that you can get a brand new Mac Mini for around $800.

A better question is perhaps: is a Mac Mini from 2015 fast enough to build apps with? I’ve built 50+ apps for iOS, Android and the web since 2009, and a fair share of those were built on a 1.2 Ghz 8GB MacBook Air from 2013. I started LearnAppMaking.com with that same trusty ol’ MacBook, and I’ve coded several successful production apps with it until 2018.

It’s traveled with me all over the world, from the beaches of Thailand, to airline lounges, to coffee shops, to coding apps with my knees behind my ears, cramped in economy class at 20.000 feet up in the air.

I don’t want to go all nostalgic on you, but I learned to code on a 100 Mhz i486 PC, when lines still started with a number. That’s a lot faster PC than the one that put man on the moon, at 46 Khz.

So, to say that a Mac Mini, or your new 2015 MacBook Pro, is fast enough, is an understatement…

If you buy a second hand Mac, make sure that it supports the latest version of macOS. Xcode and iOS versions are connected to macOS versions, so you want to buy a Mac that supports at least the current ones. You can find the max. latest version of Xcode that your Mac can run, by cross-referencing the min macOS to run in this wiki with Hardware compatibility in this wiki.

Code Swift with a Swift Sandbox

Do you really need Xcode to code apps? Ultimately, yes. But you can definitely learn Swift and code Swift without a Mac or Xcode!

Here, check this out:

func fibonacci(_ i: Int) -> Int {
if i <= 2 {
return 1
} else {
return fibonacci(i - 1) + fibonacci(i - 2)
}
}
let numbers = Array(1..10).map { fibonacci($0) }
print(numbers)

The above code runs in a Swift sandbox. The sandbox sends the Swift code to a webserver, which compiles it and returns the result. It’s the perfect tool to quickly play with some Swift code in your browser!

Swift is an open-source language, and that means you can effectively run it on any hardware.

Need more space for your Swift code? Check out the bigger Swift Sandbox right here!

Learn how to code iOS apps

Get started with Xcode and Swift

Ready to get started with iOS development? Learn how to code iOS apps with Xcode and Swift with our immersive iOS development course. Works both on Mac and PC!

Further Reading

You can’t build iOS apps without Xcode, and you need macOS to run Xcode, and a Mac to use macOS. There’s no getting around it, except for these alternatives to run Xcode on Windows:

  • Rent a Mac in the cloud (starting at $20/mo)
  • Run Xcode on Windows by installing macOS on a virtual machine
  • Build your own “Hackintosh” by installing macOS on a PC
  • Develop iOS apps on Windows with cross-platform tools
  • Get your hands on a second-hand Mac (starting at $300)
  • Learning to code with a Swift Sandbox
  • Run and compile Swift directly on Windows/Linux

Awesome. I want to wish you best of luck with building your iOS app on Windows! Here are a few projects and tutorials to consider:

Nothing is better than building apps with JavaScript. Unless you are building mobile apps. JavaScript is for building web apps, and using it to build native mobile app used to not be possible. It was hard for any web developer to dive into building native mobile apps. They have to learn Java, or Objective-C …or any programming language that was used for this purpose.

That is, until Facebook’s React Native broke this barrier. React Native comes with great advantages like building cross-platform apps for both Android and IOS. Before React Native, you had to write your code twice — one for Android and one for IOS. That’s no longer the case.

This article is an intro to the world of React Native, so get ready ?.

Why React Native?

Right, so why React native and not any other technology?

It gives us many solutions that other technologies can not afford. Here is what you can do with React Native:

Building native mobile apps

React Native allows us to write native apps in JavaScript for both iOS and Android. It gives us the ability to use all the native components like gestures, push notifications, camera, and location. There are some other JavaScript libraries for building mobile apps like ionic or PhoneGap. But those libraries use Webview, and the apps built with those technologies are not native.

Building cross platform mobile apps (iOS and Android)

Yeah, with React Native you can build mobile apps that can run on iOS and Android. This is one of the great benefits of React Native. Before Facebook created it, you had to build your app twice and with different code: one for iOS using Swift or Objective-C and one for Android using Java or Kotlin. React Native solved this problem so you can build your React Native app and it will work in iOS and Android. Awesome! ?

Write your code all in JavaScript and React

While you are building React Native apps, you will actually write JavaScript. Reactjs code allows us to build great UI and user experience components.

Getting started with react-native

Starting with react-native can be exciting, but at the same can be a bit confusing. The first step is to install it, and there are several ways to do it:

Using expo-cli:

expo-cli is a command line tool. It downloads and installs the React Native boilerplate for you, integrated with expo API (check here for installation guide). It’s an easy way to build a React Native app, and it’s the recommended way if you’ve just started with React Native.

expo-cli gives you many options. You can run and test your application on a mobile device without any configuration. Scan a QR code and your app will open up with expo mobile app. You can explore other mobile applications built with React Native on the browser over a web interface called appertize!

Using react-native-cli

The react-native-cli does the same job as expo-cli, but with a different approach and extra advantages. The apps that are installed with react-native-cli provide us the option and the ability to create our own native modules in our app. You don’t need to eject your application to be able to make native modules. Ejecting makes you able to use native modules and write you own (we will explore how to write native modules in another part).

Developing React Native apps on different platforms is a different process. Some times we need some specific configuration for a specific platform. For example to build for Android, you need to use the Android SDK, so let’s explore how this works!

Building mobile apps for Android

There are some requirements you need to install to start developing for Android. First, you have to download and configure both Android SDK and Android Studio. You can download them with this link here.

After downloading Android Studio you need to install some APIs as well. To do that open Android Studio, then click settings tab this window will open up:

First, check ✔️the platform you want your react-native to support in the SDK Platforms tab (for example Android 6.0 Marshmallow). Then switch to SDK tools.

And check Android SDK Build-Tools, Android SDK tools, and google play service. Under Android SDK Build-Tools select all the platforms:

  • Starting from 19.0.0 to 20.0.0
  • From 22.0.0 to 24.0.0
  • And 25.0.2 , 26.0.1 to 26.0.3
  • 27.0.3 and 28.0.1 to 28.02

Now we are done with SDK and Android Studio. The next step is the emulator. The emulator (or the simulator) is where we have to run and test our app. There are many different choices.

You can use Android Studio emulators. You check here how to create an emulator to use on Android Studio. Honestly I never used them. I prefer Genymotion or a real device instead.

Genymotion

Genymotion is a desktop application that provides a virtual emulator to test your application. I like to use it a lot because it’s fast. ? It gives you options to create a customized phone with the features that you can find in any real device. For example enable Wifi, Location, and Camera. I highly recommend you use Genymotion over Android Studio emulators or any other emulator.

Using real devices

Nothing is better that using real devices to run and test your app. This is because it lets you knows how you application looks like on a real device. It makes you feel the reality of your work in a way the virtual device doesn’t give. So if you have the ability to use a device, don’t hesitate.

Up to this point, we’re ok with Android — but what about iOS?

Building react-native apps for IOS

Running React Native for iOS doesn’t look much different from Android. The same React Native app that runs in Android can run on iOS as well, with some exceptions.

For example if you want to run on an iOS device, you need to have a MacOS. Talking about MacOS and iOS, you don’t need to download any extra dependencies such as the SDK for Android to run React Native on iOS.

Regarding Emulators, Xcode has nice emulators that you can use to test your React Native app. You can check this post that shows some tricks to use with Emulators.

In MacOS you can run both iOS and Android. You can definitely install Android Studio and Genymotion on MacOS. This possibility doesn’t exist on a PC where you can only run the Android emulator but not an iOS emulator. So you are lucky ?if you have a MacOS — enjoy ?.

So now we have the environment to build a React Native app and we’ve installed everything, but how is the React Native code written? It’s so simple: you will actually write Reactjs code.

You can check the official guide to get some practice with React Native. I recommend this great article to start “React Native YouTube Replica.” It will guide you step by step to create your first React Native app.

Wow! Up until now you are fine and you are coding with react-native. ? But you need to check and debug your errors and see the logs of your code. Yeah the logs!! So we need a debugger! How do you debug with React Native?

Debugging react-native

Debugging your code is very important, not just with React Native but with any other programming language. So in your React Native code, you need to know what’s going on. There are many different ways to debug a React Native app like:

Develop Mac Apps In Javascript

Develop Mac Apps In Javascript Download

Debug with Chrome devtools

React Native gives you the option to use Chrome devtools to see the logs of your app. To debug with Chrome and enable debugging mode in your emulator, on the keyboard just click Ctrl+ m.

This screen will pop-up:

And then choose Debug Js Remotely. This will open a tab in Google Chrome with this address http://localhost:8081/debugger-ui/. That’s for using Chrome devtools, what about other options?

Using React-native-debugger

React-native-debugger is a great tool to debug React Native code. It’s a desktop application that gives you many advantages. It comes with Redux devtools and React-devtools integration. You can debug the style as well. It’s actually the best debugger for React Native and it’s the one that I use. Usually it’s available on MacOS, Windows, and Linux. Check out the installation and integration guide.

I think it’s enough at this point. This is the first part of the absolute guide for building mobile apps with React Native. In the next part we are going to dive into more technical tips and issues like how we can use native components, the React native API, integration with other libraries, Redux , GraphQL and stuff like that. So subscribe to this mail-list to stay tuned when the next part comes out. Thank you for your time. ?

You can always find me on Twitter ?