Deploying apps to an iOS device without a Mac – Part 5

Navigation

Building an app to your iOS device

Now that we have a virtual Mac with Xcode running it’s time to build an app and deploy it.

Cloning and building an existing Xcode project

If you already have an Xcode project on the VM you can open it and skip to step 4.

  1. From the Xcode splash screen select « Clone an existing project ».

Note: If you have closed the splash screen you can find it in the Window menu up top, « Welcome to Xcode ».

Image 077

  1. Copy the URL of the repository of the project you wish to open in the address bar. In this example I clone a sample 1-view iOS app I’ve uploaded to Github to my Documents folder. URL: https://github.com/nanocosmo/ios-sample

Image 024

Image 026

Note: to browse projects more easily you can add your own user accounts for code-hosting platforms such as Github or Bitbucket to Xcode. In the Xcode menu up top, open Preferences… and then the Accounts tab. Click the « + » button in the bottom left and select the type of account you wish to add.

  1. In the cloned directory (Documents/ios-sample) open the project file xcode-ios-sample.xcodeproj.

Image 027

  1. Select the root of the project (1) in the left-hand column. Change the Bundle Identifier (2) to your own (see below). Make sure « automatically manage signing » (3) is checked and then select your Team (4) in the dropdown menu . A Signing Certificate (5corresponding to your Apple ID should be generated . If not then make sure you have followed all the steps in part 4.

Bundle identifiers have to be unique within the Apple ecosystem as they identify apps on the store, which means you should always modify them after cloning a project from another source.

The naming standard goes <top level domain>.<company>.<project>. If your company’s website is nanocosmo.com and your app is called ios-sample then the bundle ID should be com.nanocosmo.ios-sample. Note that the nanocosmo.com website doesn’t need to exist for you to use this bundle ID.

When working with an Apple ID that isn’t a paid developer account you can only create up to 10 bundle IDs per week. For testing purposes this is fine as you can reuse them from one project to another.

  1. If you haven’t done so plug your iOS device and connect it to the VM (see part 4, step 8). After a few seconds the device should appear in the Active Scheme toolbar at the top of Xcode. Select it from the dropdown menu.

Image 028

Image 029

  1. Now click the « Play » button to build the app. You may be prompted to unlock your device so Xcode can transfer the files.

Image 031

Image 033

  1. Before you are allowed to launch the app Xcode will warn you that you need to set the developer to « trusted » on your device.

Image 032

  1. As indicated, open the Settings on your device, General, Device Management and you should find an entry for a « developer app » in the name of the Apple ID you have used for your provisioning profile. Tap it and select « Trust ».

Note: if you delete your own apps from your device then the trust status for your developer account will be rest and you will then have to repeat that last step. Also remember that you can only have 3 of your apps on your device at any time.

  1. If all went well you can now launch the app on your iPhone/iPad.

And we’re done! You can now deploy apps to your iOS device without a Mac. I hope this guide can be of some help to someone, if you see any errors or have any suggestions feel free to post them in the comments. 

Workflows

I don’t know Objective-C or Swift and one of my main reasons for embarking on this project was to try out the cross-platform features of some of the tools I use on Windows. I’ll quickly summarize the workflows I’ve found to be effective for this purpose.

Visual Studio (Xamarin)

Xamarin is a cross-platform framework that’s integrated in the free version of Visual Studio that allows you to create native mobile apps for both Android and iOS with C# and .NET – no Swift or Objective-C required.

From version 15.6 of Visual Studio Community 2017 it is possible to pair a Mac (virtual or not) with a Windows version of Visual Studio over the network, after which you can build and deploy directly from the Visual Studio IDE on your dev machine! Setup is quite straightforward too.

Tip: to find the IP address of your VM just go into System Preferences and click Network.

Image 038

Unity

The free version of Unity can generate Xcode projects for you, then all you need to do is to open and build them on the VM. Again, no need for Swift or Objective-C.

The projects generated can be pretty massive (even if the resulting app isn’t) so my current workflow is to place them into a shared folder on my host that I then access directly from the VM. That way I don’t have to copy the files every time.

Tip: Mac OS generates .DS_Store files to store the view settings for each folder you access. They’re invisible on Mac but can be annoying on PC. To stop them cluttering your projects, start the Mac OS command-line utility Terminal and type in the following command:

defaults write com.apple.desktopservices DSDontWriteNetworkStores true

Then reboot the mac. With this .DS_Store files will no longer be generated on network shares (you may still need to remove the ones generated previously). The command to undo this change is just what you’d expect:

defaults write com.apple.desktopservices DSDontWriteNetworkStores false

 

Deploying apps to an iOS device without a Mac – Part 5

Deploying apps to an iOS device without a Mac – Part 4

Navigation

Update (27 March 2019): before continuing with this guide you may want to try updating Mac OS to version 10.14 (Mojave). At the time of this writing I was able to update to 10.14.4 directly from the App Store without having to change anything to the VM settings.

Unless you absolutely need the Xcode 10.2+ features this is completely optional and the remainder of this guide will still apply either way. As always, make a backup copy of the VM before installing any updates. 

Setting up Xcode

  1. Download Xcode 10.1 from the Apple Developer website’s « Other Downloads » section. This is the last version of Xcode that’s compatible with Mac OS 10.13.6 High Sierra

Image 071

Note: if you were able to install a more recent version of Mac OS on your VM you may be able to get the latest Xcode version directly from the App Store and skip to step 5.

If not then make sure that the version of Xcode you download from the developer site is compatible with the version of Mac OS that you are running.

  1. Safari should decompress the downloaded .xip file automatically. If it doesn’t, just double click the file in your Downloads folder.

Image 073

  1. Copy the resulting Xcode file to the Applications folder then open it to install it.

Image 074

Image 075

  1. Once installed the Xcode splash screen should appear. You can delete the .xip file.

Image 077

  1. Open the Xcode menu at the top of the screen, and click Preferences…

Image 078

  1. In the Accounts tab click the « + » button in the bottom-left corner to add your Apple ID account.

Note: this Apple ID needs to be enabled for provisioning before it can be used. All you have to do is use it to log into the Apple Developer website and accept the terms. No need to enroll in the developer program.

Image 080

Image 081

Image 001

Now would be a good time to close Xcode, shut down the VM and make a backup copy as we head for Part 5 – Building an app to your iOS device.

 

 

Deploying apps to an iOS device without a Mac – Part 4

Deploying apps to an iOS device without a Mac – Part 3

Navigation

Configuring Mac OS

  1. As seen in part 2 a notification might pop up telling you that updates are available. Do not attempt to update the machine before you have backed up the VM! For now, select Later and Remind me tomorrow, then when asked whether to turn on Automatic Updates select Not now.

Image 044

Image 045

  1. Open the System Preferences in the dock and click on App Store. Disable all automatic updates.

Image 046

Image 048

It is highly recommended you take a snapshot or backup of the VM whenever you want to try to update the OS! With this setup for example I wasn’t able to install security update 2019-002, the machine would crash upon rebooting. I had to restore my backup and ignore the update.

Note: Although this version of VMWare Workstation Player doesn’t have a snapshot feature you may back up the VM manually by turning it off and then making a backup copy of the VM folder you specified in part 1. Then you can go back to the App Store section of System Preferences and click Show Updates to install them manually.

  1. Time to install the guest additions! Go into the Player menu, Manage, then Install VMWare Tools… and double-click the Install VMWare Tools icon that pops up.

Image 050

Image 051

  1. Follow the instructions.

Image 052

Image 054

Image 055

Image 056

  1. When the System Extension Blocked dialog appears, click Open Security Preferences then in the Security & Privacy window that opens click the Allow button next to the line « System software from developer VMWare, Inc. was blocked from loading ».

Image 057

Image 058

Image 059

  1. You can then Restart the VM.

Enhanced features are now available: resizing the WMWare Player window will adjust the resolution appropriately,  the mouse cursor is now integrated seamlessly, a Shared Folders feature becomes available, etc.

Note: after rebooting the Sytem Extension Blocked dialog may pop up again, simply repeat step 5 to get rid of it.

  1. Start iTunes from the dock and agree to the Terms of Service when prompted

Image 061

  1. Plug your iOS device into the host computer. You may have to unlock the device itself to enable the USB connection.
  2. Go into the Player menu, Removable Devices to find it (in this example, an iPad). Then click Connect, which will disconnect the device from your host machine and connect it to the VM.

Image 060

  1. After a few seconds the authorization process should start: authorize the pairing on both the VM and the iOS device, which should then be identified correctly in iTunes.

Image 062

Image 064

If the iOS device won’t show in the VM first make sure the USB compatibility setting is set to USB 2.0 in the Virtual Machine Settings, and that Show all USB input devices is selected. Also make sure that the iOS device is unlocked as you plug it in.

Image 065

If the options are already set correctly then try using a different USB port on your host machine and repeat steps 8-9.

  1. As you plug in your device the following dialog may pop up in VMWare Workstation Player, allowing you to set a default behavior.

Image 013

Note: if you want to change this at any point then go back to the menu described in step 9 and click Forget connection rule.

  1. If you couldn’t find the proper keyboard layout when you installed the OS you might be able to find it now in System Settings, Keyboard, Input Sources. Click the « + » button in the bottom-left.

Image 039

  1. Then find your language and keyboard variant (« PC » if you use a regular PC keyboard).

Image 040

Now would be a great time to take a backup of the VM before we move on to Part 4 – Setting up Xcode.

Deploying apps to an iOS device without a Mac – Part 3

Deploying apps to an iOS device without a Mac – Part 2

Navigation

Installing Mac OS X

  1. After a short while the VM will boot into our Mac OS ISO. First, start Disk Utility.

Image 017

  1. You need to format the VMWare Virtual SATA Hard Drive Media before you can install the OS: select it under Internal on the left, click Erase in the top menu, rename the volume if you like and click the Erase button.

Image 018

Image 021

  1. Close the Disk Utility to get back to the Mac OS Utilities and double-click on Install macOS.

Image 023

Image 024

Image 025

  1. Select the disk you just formatted and click Install.

Image 026

  1. The installer then partitions the disk, copies the installation files, and reboots.

Image 027

Note: If you find yourself back to Mac OS Utilities after the reboot you might need to eject the Mac OS ISO from the virtual disc drive to boot from the newly created partition.

  1. You will then go through a basic setup where you pick your country, keyboard etc.

Image 015

Image 029

Note: don’t worry if you cannot find your exact keyboard layout right away, you can always change it later.

Image 030

  1. Use the same Apple ID you also use on your iOS device to log in. Ignore any error relating to iCloud.

Image 031

Image 032

Image 033

  1. Create the user account that will be used on the Mac.

Image 035

  1. Click Customize Settings and make sure location services are disabled.

Image 036

Image 037

  1. Pick a Time Zone and disable Analytics. Then, after a short time your desktop should appear.

Image 038

Image 040

Image 041

  1. If all went well you should be greeted by the High Sierra desktop.

Image 042

You might be prompted to install some updates – do NOT install them before you have had a chance to backup the VM!

We’ll disable automatic updates in Part 3 – Configuring Mac OS.

Deploying apps to an iOS device without a Mac – Part 2

Deploying apps to an iOS device without a Mac – Part 1

Navigation

Introduction

If, like me, you’re a Unity or Xamarin hobbyist who develops primarily on a Windows PC but owns an iPhone and/or an iPad, you’ve probably run into the hurdle of requiring an actual Apple-brand Mac computer just to compile and deploy your apps to your mobile device.

This guide will explain how to get around that restriction by using a Windows 10* computer (the « host ») to run Mac OS X and Xcode on a virtual machine (the « guest »)  which will allow us to deploy apps to an iOS device without requiring an actual Mac.

Note that the following is against Apple’s Terms of Service so use at your own risk.

Although I have not tested it myself this should also work on a Linux host

Requirements

  • A host computer powerful enough to run a virtual machine (VM)
    • At least 8GB RAM (a minimum of 4GB is required for the guest)
    • 50GB of drive space to allocate for the guest
    • An Intel CPU supporting Intel Virtualization Technology (VT-x). Make sure that this feature is enabled in the BIOS
  • VMWare Workstation 15 Player (free for non-commercial use), the virtualization software that will run the VM. Due to Apple’s ToS prohibiting running Mac OS on non-Apple hardware the option to run Mac OS guest is locked out, which is where the next item comes in:
  • DrDonk’s Unlocker v3.0, a utility that restores VMWare Workstation Player’s Mac OS guest functionality on non-Apple hardware
  • A bootable ISO file of Mac OS 10.13.6 High Sierra to install on the VM. You should be able to find this without too much trouble if you look around
  • An iOS device, iPad or iPhone, to deploy your apps to
  • A (free) Apple Developer account: just an Apple ID that you activate on the Apple Developer website. The free version will allow you to test your app on your iPhone/iPad.

Limitations of the free Apple Developer account

As of this writing the following limitations apply to an Apple ID that isn’t enrolled in the paid developer program:

  • You cannot publish apps to the app store
  • You can only have 3 apps on a device at a time
  • You can only create 10 bundle identifiers per week
  • Apps will stop working on your device after 7 days unless you build/deploy them again

Creating the VM

  1. Install VMWare Workstation 15 PlayerDon’t start it up before the next step.
  2. Remove the Mac OS hardware restriction with DrDonk’s Unlocker v3.0.

Download it as a zip file from github, extract it to a folder on your host and then run the script win-install.cmd with admin rights (right-click and Run as administrator). The WMWare Player has to be closed for this to work.

Image 001

  1. Start VMWare Workstation 15 Player and Create a new virtual machine.

Image 002

  1. Select « I will install the operating system later ».

Image 003

  1. Select Apple Mac OS X and pick the version that corresponds to the Mac OS ISO you have (here macOS 10.13).

Image 004

Note: if Apple Mac OS X is missing from that list then something went wrong with the unlocker in step 2. Make sure to follow the instructions contained in the README file included with the unlocker.

  1. Name the VM and select a location to put it in.

Image 005

  1. The suggested maximum disk size (40GB) is a bit low for Xcode but you can change this later. I used 60GB for extra room and left it as a single file.

Image 006

  1. Click Customize Hardware.

Image 007

Image 008

For reference I changed the following setting for my Windows 10 host (Intel i7-7700k CPU, 16GB RAM). If a setting isn’t mentioned here it means I kept the default value.

a. Memory: 8GB. You might not need that much to use the VM but it does make the installation process faster and you can always change it later (min: 4GB)

b. Processors: 4, half the cores I had available on my host

c. New CD/DVD (SATA): select your Mac OS ISO image file here so the VM can boot from it

Image 009

d. USB Controller: make sure to change USB compatibility to USB 2.0 and check show all USB input devices or the iPhone/iPad will not show up in the VM

Image 010

e. Display: if you have multiple monitors you may want to change the display settings so the VM only uses 1. The guest add-ons will allow you to resize the window to change the resolution at will. No 3D acceleration because it isn’t supported for Mac OS guests

Image 011

  1. Now close the Hardware dialog, click Finish and the VM will appear in the Player. Select it and click Play: the VM will boot from the ISO and the installation process should start.

Image 013

Image 014

Note: by default clicking inside the VM window will « capture » your mouse cursor. To get it back you can try pressing ALT+CTRL or CTRL+G. Installing the VMWare Tools will allow seamless cursor integration when the guest is running (see part 3).

Continued in Part 2 – Installing  Mac OS.

Deploying apps to an iOS device without a Mac – Part 1