Windows -> iOS Rsync/Remote Build Guide (4.8)

Hi all!

I’ve spent the better part of the last couple weeks getting my Windows iOS project to remote build on my Macbook, since building code projects for iOS directly on a Windows machine isn’t supported yet.

I put together a guide for my own future reference, and thought I would share it here to hopefully save someone the headaches I went through getting this under control;


-- [INTRO] --

UE4 Remote Build Guide
Version 1.0
Updated Aug 01-2015
by bzxo + friends

This guide will help you build an iOS Code project residing on a Windows machine, using a remote Mac.

--- [MAC] ---

1)  Download and install Xcode

2)  Download the UE4 source code to your Mac
	2a)  Open a terminal window on your Mac, and cd to the root directory. (cd /)
	2b)  Create a new directory called UE4 at the root directory. (sudo mkdir UE4)
	2c)  Make sure the permissions are set for the new directory. (sudo chmod 777 UE4) (important)
	2d)  Get the 4.8 Release Source Code from Github and put it in the UE4 directory you just created. (git clone --url of your fork here--)
		Alternatively, download ZIP from Github, unpack in ./UE4, and run setup.sh

3)  Export cert and provisioning profiles from Xcode
	3a) Add your Apple Dev Account in Xcode (Preferences->Accounts)
	3c) Xcode > Apple IDs > Details > Provisioning Profiles > "Show in Finder" > Copy .mobileprovision files to folder on PC (or USB stick)
	3d) Xcode > Apple IDs > Details > Signing Identities > "Export" > Input password and export .p12 files to folder on PC (or USB stick)
	3e) Open Keychain Access, choose the "My Certificates" category, and move your certificates from "login" to "System"

4)  Setup RSync daemon
	4a) Make sure you are an administrator on your Mac. You may need to use sudo to create some of the files below.
	4b) Open up Terminal and cd to /Library/LaunchDaemons
		Here we’ll create a service definition which will allow the daemon to start (through launchd).
	4c) Download [https://taoofmac.com/media/cli/rsync/rsync.plist.txt] and copy it into the directory. This file should have the .plist extension.
		(Pastebin mirror if download is broken; [http://pastebin.com/k0tdzguE])
		(e.g. cp ~/Downloads/rsync.plist)
	4d) Check the directory and make sure the owner of the file is root, the group is wheel, and the permissions are rw-r--r--.
		Note: If the permissions are not correct, the daemon will not load. You can check if launchd is loading the module correctly by running: sudo launchctl load /Library/LaunchDaemons/rsync.plist
	4e) cd to /etc
	4f) Create a new file called rsyncd.conf
		Here, we create a definition for the “share” the rsync daemon will host.

		[root]
		   path = /
		   hosts allow = [YOUR PC NAME]
		   uid = root
		   gid = wheel
		   read only = false
		   comment = Root volume
	   
		    Essentially, this creates a share called root which points to the root path of the volume ( / ), is readeadable/writeable, only allows connections from the host at [PC NAME], and uses root permissions.

	4g) Check the directory and make sure the owner of the file is root, the group is wheel, and the permissions are rw-r-----.
	4h) Now we have everything we need run. I didn't need to restart or do anything else - it just worked. If for some reason you can't rsync right away, you may need to restart your machine.
	     If you port scan (or nmap) your machine, you’ll probably see that the default rsync port is closed (port 873). This is fine, since Launchd will open the port when required.	
	
--- [PC] ---

1) Download the UE4 source code to your PC
	1a)  Create a directory at the root of your drive called UE4 just as you did on the Mac.
	1b)  Clone the same fork 4.8 release here.
	1c)  Run the GenerateProjectFiles.bat
	1d)  Open the UE4 solution and build it;  Studio is set to Development Editor - not Development.

2)  Download and install DeltaCopy
	2a) Start the DeltaCopy CLIENT and add new Profile;
	     Username = [Mac Username], Hostname = [Mac Name], and test the connection.
	     DeltaCopy will succeed in connecting if the Rsync daemon is running on your Mac - you can see first if you're able to connect to \\Mac Computer] through Explorer, to make sure you're on the same network.

3)  Open the UE4Editor.exe found in C:\UE4\Engine\Binaries\Win64.
	3a) Create a new code base project, be sure to uncheck the 'Include Starter Content', and put the project in the C:/UE4 Folder

4)  Setup your project iOS settings
	4a) Go to Edit -> Project Settings -> iOS -> and be sure the project is configured for IOS.
	4b) Import the Mobile Provision that we exported earlier. This will be automatically copied to a location in your Documents folder.
	4c) Import the Certificate (.p12 that we earlier exported from Xcode), input password. This will register the certificate globally on your PC.
		 Since the editor copies and registers these files, you can now unplug your USB stick or remove the files you exported earlier.
		NOTE:
		 If importing through the editor doesn't work, open C:\UE4\Engine\Binaries\DotNET\IOS\IPhonePackager.exe,  click the Already Registered tab, select your test project, and import your certificate through there.
		 IPP might crash, hang, or throw an error message about a missing .plist file, but it should still work. Shut down IPP when done and refresh your iOS settings in the editor.
	4d) Set bundle identifier to com.companyname.yourgame (make sure this matches the string in your mobile provision)

5)  In the same tab, find the Remote Build Options (tiny hidden arrow)
	5a) Enter the Remote Server Name (Computer name of the Mac)
	5b) Enter the Remote User Name (User name of the Mac)
	5c) Press the [Generate SSH Key] button
	5d) Enter Yes into the terminal
	5e) Enter the password of the Mac computer
	5f) Press Enter twice to enter an empty passphrase
	5g) Enter the password of the Mac computer again

6)  Finally, Package Project -> iOS
	6a) If successful, files should copy over to /Users/[User name]/UE4/Builds/[PC Name] on your Mac.
	     If your Windows computer says that it's uploading but nothing is appearing in this folder on your Mac, packaging will fail.
	     If you end up with error messages, make sure to check that you can access your Mac's file system from your Windows computer, repair disk permissions on your Mac, and check that the above folder has sufficient permissions.
	6b) If everything goes right, you will have an IPA in the Binaries/iOS folder of your Windows project folder. It can take a while to build, as it has to upload everything to your Mac and build it.
	     Install the IPA and test it, or you can use the Launch On iOS Device button, which will make the app appear on your device automatically.
   
--- [END] ---

-- [NOTES] --
	* Imported certificate shows up as invalid in the editor
		If you just created a certificate and provision and the editor can't validate it, you might have run into a bug where the editor checks local time for certificate validity, and then UTC time to confirm start and end dates.
		This means that if you are in a different time zone, you might have to wait up to 24 hours for the certificate to auto-activate in the Project Settings->iOS tab. Just check again later.

	* Clearing out old certificates
		To delete old certificates on a Windows computer, run certmgr.msc, go to Personal->Certificates, and delete the appropriate developer and/or distribution certs.
		
	* Clearing out old mobileprovisions
		To delete old mobileprovisions, go to [C:\Users\[UserName]\AppData\Local\Apple Computer\MobileDevice\Provisioning Profiles] and delete whichever files aren't needed.

-- [CREDITS] --
		Written, tested, compiled by bzxo

	SOURCES;
		Awdogsgo2heaven's thread for pre-Rsync building; https://forums.unrealengine.com/archive/index.php/t-9122.html
		TaoofMac, Setting up Rsync;  https://taoofmac.com/media/cli/rsync/howto.html
		wittlief, Generating SSH Key; https://answers.unrealengine.com/questions/236362/bug-report-platform-ios-remote-build-options-gener.html
		psauer, notes on time; https://answers.unrealengine.com/questions/231483/ios-unable-to-find-valid-certificate-when-importin.html
		markusvdr, deleting old certs; https://answers.unrealengine.com/questions/246745/48-importing-certificate-please-wait-mac-and-windo.html
		Josh Adams, deleting old mobileprovisions; https://answers.unrealengine.com/questions/223227/remove-obsolete-mobileprovision-profiles-ios.html
		psauer, moving keys to System keychain; https://answers.unrealengine.com/questions/261665/rsync-remote-certificates-not-found.html

Thanks bzxo for putting up the guide!

I’m still using the UnrealRemoteTool for building ios project on windows (Tried rsync once but not getting much luck). I guess I should give rsync another try then.

I followed this guide and was able to start packaging a New Project. Files where being copied to my mac until I got an error (I don’t remember the error, going to try again today). So I can confirm it works up to that part.

Can this work using the Editor installed with the Launcher? And with a project in another Location?, because my perforce workspace is elsewhere.
With my project I see the “Remote Build Options” grayed out.

As far as I know it’s not possible with the binary version of the editor, and the project needs to be in C:\UE4.

Thanks for this guide! I can confirm that it also works for UE 4.9.

I ran into a problem on my Windows 10 PC, and I think Windows 8 users will have it too. If when you’re trying to package for iOS the editor seems to do nothing after printing the following line to the log…


UnrealBuildTool: Doing date +"%s" && sysctl hw.memsize | awk '{print $2}' && sysctl hw.logicalcpu | awk '{print $2}'

… the problem is that DeltaCopy is not able to read the SSH key you just created. To fix it, you’ll need to install Cygwin. Use the Cygwin terminal to navigate to the folder where the key is stored, and run “ls -l”. You’ll probably see something like this:


-rw------- 1 Leo Leo 1675 sep. 16 17:31 RemoteToolChainPrivate.key

The fact that the group name is the same as your user name is messing things up. To fix it, just run


chgrp Users RemoteToolChainPrivate.key

If that doesn’t work, you’ll need to replace Users with the word that means the same in the language of your Windows installation.

Edit: I had another problem. You can read how I fixed it here: https://answers.unrealengine.com/questions/305314/remote-packaging-for-ios-fails-on-windows-10-inclu.html

I have set the remote build system up again on the latest software configuration available at this time: UE 4.9.2 + Windows 10 + OS X El Capitan. It still works if you follow all instructions posted on this thread. Furthermore, I have found that it’s not necessary to download the UE source code on the Mac, nor to install the binary version of the editor. You just need to set Xcode and Rsync up. Every UE file which is required for building and packaging will be copied automatically from the Windows 10 PC.

You don’t need cygwin. Just navigate to the file in Explorer, right-click it, go to the “Security” tab, click “Advanced” and change the owner to “Users” (or it’s equivalent in your language then add full permissions to “Users”.

I’m getting stuck on the generating the SSH key through Unreal. It’s saying:

ssh: connect to host <mac_name> port 22: Connection refused

DeltaCopy was connecting fine when I create the profile, but I am unsure what that step is actually accomplishing. Is there another way I can create an SSH key manually that UE4 will accept?

Try connecting to your Mac using an explorer window (\computer-name) and see if you can access it at all. Make sure you have the right username, and password if you use that.

I just wanted to let people know not only do you have to MOVE the cert from the login keychain to the SYSTEM keychain but you must also make sure you are NOT doing that through a remote session. It took me days to realize the latest OS (El Capi…) does not allow it!!!

You should check whether SSH is enabled. On OS X, go to System Preferences -> Sharing -> Remote Login.

Is it also possible to do this without “Provisioning Profiles”?

No. You need an Apple Developer Program membership.

Thanks for the excellent guide bzxo.

The only OSX Apple device I currently have access to is a 13" Macbook Air (Mid 2011).
This device only has 4Gb (not upgradable / soldered to the motherboard).
It would appear recent versions of XCode require 6Gb, but I am not sure how much the XCode IDE itself eats up (as opposed to headless command line).

Has anyone got cross compilation of UE4 working on a 4Gb machine?
Or managed to get this working in a ‘rented online’ OSX environment?
Would try myself, but my Apple developer membership has lapsed and will have to pay for another year to try this out (was unused due to lack of access to OSX hardware)…

When I press “Generate SSH Key” I get an error in the terminal that says “Couldn’t compute FAST_CWD pointer”. Has anyone run into this issue? I tried updating Cygwin but it didn’t fix the issue.

Thanks!
I was testing with UE 4.24.3 and it was complaining about permissions 660 on the file RemoteToolChainPrivate.key.
Your advice solved the issue for me an UE4 is now Rsyncing into my mac and went quite far in the process.
However, I’m now stucked at shader-compiling not sure whats going on there

I am testing this on my MacBook Air which has only 4GB RAM and using UE 4.24.3 on my PC.
After a few problems in the process, (see my comment above), I am able to get UE4 remote compiling over my macbook.
Now it’s been taking forever in the shader-compiling stage, will have to see how that goes.