📜 ⬆️ ⬇️

Development of code-based UE4 projects for iOS in Windows



One of the most frequently asked questions on the official forum of Unreal Engine 4 , regarding development for iOS, is the ability to develop code-based projects on Windows, without having to buy and use Mac OS X as required by official documentation. There are solutions, but they are poorly defined and can take a lot of time for trial and error. On the difficulties of translation into Russian and can not speak. So this tutorial was born, which I want to share with you.


For starters, not a lot of facts. UE4 officially allows to develop games for iOS only on Mac OS X and Xcode, respectively. Agree, especially in our country, to buy a powerful mac comparable in performance to an existing PC, the case is rather expensive. And not everyone will want to retrain for the new OS and development environment, and if it is decided, it will spend a decent amount of working time on it before it reaches the previous level of efficiency.
')
I’ll just make a reservation that it’s impossible to do completely without a computer (PC or Mac) running OS X, at least in the current version of the engine. However, there is a fairly optimal and compromise solution to the problem. Already, all users of the latest versions of the engine (4.2.x and above) who have access to its sources on GitHub (or, for example, downloaded them from all known torrent trackers), have the undocumented ability to configure a computer running Mac OS X as a server assembling and compiling projects, and developing the project itself and testing it on devices only from under Windows. You’ll have to periodically look in the Mac and check if it is still working, or if you meet its ends with a constant compilation of the code.

What is needed for this?


As already mentioned, you need a computer running Mac OS X (10.8 and higher). You can buy a used Mac or Mac Book or run OS X in a virtual machine. How and what your OS X will work on is up to you. As an example, we are currently using the Mac Mini (Late 2009), bought with it cheaply. He copes with his tasks, but in the future we will definitely put the machine on faster (the most important is the processor and the disk system). It makes sense to look for a computer on ebay (unless of course you have time to wait with delivery for 2-3 weeks; we did not have).

So, suppose that we have everything that is needed, namely: a working PC running Windows (7 SP1 and higher), as well as a computer running OS X (10.8 and higher). Computers must be connected to a normal local area network. In theory, the proposed method is as follows. In the UE4 sources, there is the UnrealRemoteTool program. By running it on OS X, we can send it commands to execute from a remote computer (compile, package, etc.). In our case, the commands will be sent from a PC running under Windows and on which development is underway in UE4: the content is edited, the project code is written, etc. In the net balance, after correct configuration, we can directly compile and package the project for iOS directly from the UE4 editor as it is done in the case of a regular PC build. From there, you can install ready-made ipa on all iOS devices connected to your PC. The following is a detailed instruction on how to configure all the programs and equipment on both systems. Go

Step 1: First we need to access the UE4 sources. If you already have them from unofficial sources, you can skip this step. If you are an officially registered developer of Unreal Engine 4 and have an active subscription, then you need to do the following. Go to the GitHub website and register there if you do not have an account yet. Sign under it. Next, go to the Unreal Engine website - log in there and in your account settings (section Account) indicate your GitHub account in the corresponding line. Save the changes. Next, your path lies on the Epic Games GH page on GitHub: github.com/EpicGames/ - select UnrealEngine in the list of repositories. In the upper right corner, click the Fork button, and in the appeared window with the account selection, select your GitHub account. Be sure to pick up version 4.2 and later. After that you will be moved to the page of your personal branch of the engine. It is recommended that you read the entire description on the page before proceeding further, but the main thing that you need to do here is to download the two archives Required_1of2.zip and Required_2of2.zip , which are located in the paragraph Getting up and running. It remains to download GitHub clients for local work with source codes. For Windows, you can download it here , and for OS X, right here .

Next, for each operating system you need to perform your own set of steps separately. Let's start with Mac OS X, and finish the configuration already on the PC, after which you can freely develop for the iOS platform.

Mac os x


Step 2: First of all, you need to upgrade your system to at least version 10.8, and better to the latest version of Maveriks at the moment (10.9.x). In the upper left corner click on the apple, select About This Mac -> Software Update. You will be transferred to the AppStore and if updates are available, install them.

Step 3: Then install Xcode. It is free, you can download it from here .

Step 4: In order to develop projects for iOS, you need to be registered with the Apple Developer Program. The program costs $ 99 / year. Now it has become quite easy to get the status of a developer, no need to send any faxes for this. For those who are not registered yet, I advise you to start from here . For those who are already registered, you need to create a certificate and a Provision profile based on it for your game, and it is also advisable to think about AppID in order to fully have the opportunity to test GameCenter, iCloud, IAP and Push messages. All this can be done at the Member Center . Do everything exactly with the description on the site and the process will not take you much time. Please note that to install the Provision profile on an OS X computer, just download it and open it with a double click. Xcode will open and that's it. No additional messages will appear - this is normal. With the installation of certificates on a computer, everything is a little more complicated, but nevertheless more transparent (you can see them yourself in the Keychain application after importing). The only problem is that former UDK developers who have a certificate (which can be downloaded from the Apple site) may have problems, but do not have a private and public key that was used to generate the certificate. In this case, go to the Apple website, create a new certificate, again following the instructions, and then create a new Provision Profile based on it. AppID will not suffer from these actions, as well as all existing applications and provision / distribution profiles.

Step 5: After you import the certificate and the Provision profile into the system, you need to export the certificate and its private key back. To do this, open Applications -> Utilities -> Keychain Access.app. In the top-left box, select login , select My Certificates below, and then find your imported certificate in the list on the right. Right click on it and select Export . First, export it with the * .cer extension, and then expand it, select the key that appears and export it by selecting the * .p12 extension. You will need these two files, as well as your Provision profile on your PC later, so save them to a USB flash drive or, for example, to Dropbox.

Step 6: Now we need to pick up the source from GitHub. To do this, open the terminal OS X: Applications -> Unitilites -> Terminal.app. You can do without it, but it will be faster with it, and much more convenient as a result. Soon you will understand why.

Step 7: Go to the root directory by entering the command:

cd / 

Note: If you are asked to enter a password, enter it, not paying attention to the stillness of the carriage. It should be so. Enter the password blindly and press Enter.

Step 8: Create a new folder in the root directory:

 sudo mkdir UE4 

Step 9: Make sure that this folder has all permissions:

 sudo chmod 777 UE4 

Step 10: Next, install the downloaded GitHub client on Mac. Run it, log in with your account. In the left column you will see a list of accounts from which you can download repositories: select your account. In the list of repositories appearing on the right, select * Your_Account * / UnrealEngine and click Clone To Computer . For the cloning folder, specify the UE4 folder you created earlier, located in the root directory of the hard disk.

IMPORTANT: Clearly follow all the paths and directories for cloning repositories, creating UE4 projects, etc., otherwise your project will simply not build up due to files not found here and there. At the moment, the system is very sensitive to changing the location of the source of the engine and the projects themselves!

Step 11: Please note that previously downloaded zip files do not need to be unpacked on OS X. All you need is source code.

Step 12: After the source is copied to your computer, return to the command line and run the following command:

 for (( ; ; )) ; do ./UnrealRemoteTool; done 

It will launch the UnrealRemoteTool utility, which from now on will listen to commands from your Windows PC. Please note that we run it in a loop. If suddenly the utility closes due to an error, for example, it will open again and continue working. Thus, you can always keep your OS X computer turned on and at any time to pack iOS projects with it. In case of a complete power off of the Mac, you can configure it to turn on after an abnormal shutdown. This is done as follows: System Preferences -> Energy Saver enable the Start up automatically checkbox after a power failure . Now, in order not to start the Terminal manually each time and not execute the for command to start the UnrealRemoteTool, we will execute the following set of commands in the Terminal window (we need to open a new window, because the current one is busy waiting for commands from UnrealRemoteTool):

 cd /UE4/UnrealEngine/Engine/Build/IOS sudo chmod 777 /UE4/UnrealEngine/Engine/Build/IOS touch StartUnrealRemoteTool.command sudo chmod 777 StartUnrealRemoteTool.command open /UE4/UnrealEngine/Engine/Build/IOS 

you will see a Finder window with an IOS directory. Find the StartUnrealRemoteTool.command file there. Right-click on it, select the menu item Open With -> TextEdit.app

In the file that opens, write the following commands

 cd /UE4/UnrealEngine/Engine/Build/IOS for (( ; ; )) ; do ./UnrealRemoteTool; done 

click at the very top, to the left File -> Save. Now open the System Preferences -> User & Groups system settings, select your account in the left window, and go to the Login Items tab on the left-top. Click on the plus sign on the opened tab, go to the root and select the StartUnrealRemoteTool.command file. Thus, every time the system starts, UnrealRemoteTool will start automatically and your Mac will always be ready to work.

Step 13: In OS X, we just need to find out the name of your computer and configure Files Sharing. Go to System Preferences -> Sharing and check the box next to File Sharing . Select Allow access for All Users . At the top of the window you will see the name of your computer. Click on Edit and re-name it in the appeared window so that there are no spaces in it. For example HGSMacMini. Note the postfix .local at the end of your computer name. Write the whole name together with the postfix somewhere on a piece of paper, we will need it soon.

Windows


Step 14: To work with code-based projects in Windows and to be able to compile the engine itself from source, you must install Visual Studio 2013 (not below). The free Express version will do; Download it here.

Step 15: Run VS2013 once after the installation is completed; select a theme design; choose a familiar environment configuration; on the offer to log in - log in (you will need it if you later want to use TFS Online as a version control system)

Step 16: Next, install the GitHub client on Windows. After installation, log in with your account, and you can skip the second and third step. Next, open the client settings (gear, right-top) and in the Clone Path field, enter C: \ UE4 - click the Update button. Now you can download the source from the Internet. Click on the plus sign in the upper-left corner, go to the Clone tab. In the same way as it was done in OS X, select your account in the left column, and in the right UnrealEngine and click Clone at the bottom of the window.

Step 17: Optional: If you plan to work with TFS as a version control system, then at this stage you need to disable the pickup project in GitHub, otherwise it will knock you out from under the TFS, whenever you try to open the Solution project in VS2013. On the client’s main screen, the UnrealEngine project should be displayed in the left column. Right-click on it and select Remove . Next, close GitHub, go to the C: \ UE4 \ UnrealEngine folder and delete the hidden .git folder - if it is not deleted, restart the computer or use the unlocker program and delete it.

Step 18: After the sources are copied, one by one, open the previously downloaded zip files (instead of the standard Windows utility, better use WinRar or others): Required_1of2.zip and Required_2of2.zip - extract their contents to the C: \ UE4 \ UnrealEngine folder with substitute.

Step 19: Next, in the C: \ UE4 \ UnrealEngine folder, create a text file and change its name along with the extension to the following: UE4Games.uprojectdirs - open it in Notepad ++ or in normal Notepad and add `. /` To it (without quotes, only point and slash). Save the file.

Step 20: Now go to the : \ UE4 \ UnrealEngine \ Engine \ Saved \ UnrealBuildTool folder and open the BuildConfiguration.xml file (it is best to open this and all subsequent files in Notepad ++, so as not to damage the encoding. Use the paste carefully).

At the bottom, before the closing tag (in version 4.3, this section is already at the beginning of the configuration file — you need to edit it) insert the following xml code:

 <RemoteToolChain>    <PotentialServerNames>        <Item>AlternativeServer</Item>    </PotentialServerNames>    <RemoteServerName>HGSMacMini.local</RemoteServerName> </RemoteToolChain> 

replacing HGSMacMini.local with the name of your OS X computer that was previously recorded. Save the file.

Step 21: Now take turns opening the following two files:

C: \ UE4 \ UnrealEngine \ Engine \ Binaries \ DotNET \ IOS \ IPhonePackager.exe.config
C: \ UE4 \ UnrealEngine \ Engine \ Source \ Programs \ IOS \ iPhonePackager \ Properties \ iPhonePackager.exe.config

and make sure that the section contains the following line (if it does not exist, insert it, or false to correct it):

 <loadFromRemoteSources enabled="true"/> 

Save files if changes are made.

Step 22: Go to the folder C: \ UE4 \ UnrealEngine \ Engine \ Build \ IOS and open the file UE4Game-Info.plist (now right in Notepad ++) and find the CFBundleURLName property. You need to replace it with the value of the Bundle specified when creating your Provision profile, which was installed in OS X. Usually it looks like this: `com.AwesomeDeveloper.CoolGame` is without quotes. Instead of CoolGame, it can be * if you had a bundle set up this way (to release several games). This is normal. Next, find the line:

 <string>com.epicgames.${BUNDLE_IDENTIFIER}</string> 

and replace com.epicgames with the value from your bundle, but this time deliberately omitting the name of the game. Save the file before making sure that the encoding matches UTF-8 without BOM. This can be done by clicking the Encoding item in the Notepad ++ menu.

Step 23: It's time to think about our certificate and provision profile. Without leaving the folder, copy your provision profile into it, which was installed in OS X, and rename it to UE4Game.mobileprovision

Step 24: It remains to import the certificate. Click on the Start button and type in the search name MMC.exe and press Enter. In the window that appears, click File -> Add / Remove Snap-in ... In the window that appears, in the left column, select Certificates from the list, then click the Add button, in the dialog box that appears, select My user account and click Finish, and then OK. The dialog closes, and the Certificates - Current User item appears in the left column of the main window. Expand it and select the folder Personal -> Certificates. Right-click on the center of the window where certificates are displayed and select All Tasks -> Import. In the wizard window that appears, click Next. Find your certificate exported to OS X on the disk, select it. Click Next, and then Finish. After that, click All Tasks -> Import -> Next again. But this time, find the exported private key with the extension * .p12 by selecting it in advance among the filters. Then click Next, you will be prompted to set a password for it. Skip, otherwise when automatically packing the project in UE4, access denials are possible. And also click Next, then Finish. All the preparatory work is completed. Close MMC.exe. On the proposal to continue, refuse. For certificates, this has nothing to do.

Step 25: Finally, you can run the C: \ UE4 \ UnrealEngine \ GenerateProjectFiles.bat file to generate the engine project and utilities. As soon as the script runs, run the generated UE4.sln for the first time (this is the solution of the engine itself). Upstairs, in the project settings, select Development Editor and Win64 , after watching this video , so that there are no questions about where to choose Win64. Next in the Solution Explorer, select the project UE4, right-click on it and select Build . The engine will be compiled for 15-40 minutes. It all depends on the processor and disk system, as noted earlier. After the assembly of the engine itself (project UE4) is completed, in the Solution Explorer open the Programs filter and build the UnrealFrontend project to get the same program output. It is useful for profiling the code, as well as to avoid error messages when packing and installing projects on devices through the Launch Tool in the editor.

Step 26: Upon completion of the build, you can open the ready-made UE4 editor, which is located here: C: \ UE4 \ UnrealEngine \ Engine \ Binaries \ Win64 \ UE4Editor.exe. At the start, you will be asked to create a project. Select Code Base Project , uncheck the Include Starter Content checkbox, and select C: \ UE4 \ UnrealEngine \ as the directory - I remind you that the directory is very important! Then click Create Project .

Step 27: The project creation window will close and open Visual Studio 2013 with the source code of your new code-based project. All you need is to select your project in Solution Explorer and right-click on it to select Build.

Step 28: After compiling the project, run UE4Editor.exe again and select your project from the list. After opening, you will be taken to a map created by default suitable for testing the basic functionality of the project (the ability to build and deploy on devices). Therefore, save this map to your project directory. For a start, it will serve you as your starting card, for packing the project. Next, open the settings Edit -> Project Settings -> Maps & Modes and select the newly saved map in the Game Default Map field. Just below, make sure that the Default GameMode field is the GameMode of your project that you created and compiled. For example IdolGameMode. If it is not selected, select it from the list.

Step 29: Without leaving the settings, go to the Packaging section and expand the top section of the Project . Uncheck Full Rebuild otherwise, every time you build a project, the whole engine will be recompiled, and this is a very, very long time! Full Rebuild should be used only when assembling release or other important builds, where a full build is really needed.

Step 30: The last step is to configure the project under iOS. While in the settings, go to the iOS section and click on the configuration button. Everything, your project is ready to be packed and loaded onto devices.

Step 31: In order to pack a project into a * .ipa file, close the settings and click in the main window of the File -> Package Project -> iOS editor. Select the directory where you want to put the finished ipa file and click OK. The compilation and packaging of the project will begin. At the end of the packing, a folder with the name of the platform for which the assembly was made (in our case, this is iOS) will appear in the specified directory and you will find the coveted ipa file with the game in it. It should be noted that the packing can be quite long, and its progress can be monitored in the Window -> Output Log. The process can take from several minutes to several hours if you have a weak machine under OS X. It all depends on your financial capabilities. But it is worth noting that after the first compilation and regular change only the content of the project in the editor itself, the packing takes less than a minute even on a weak Mac Mini.

Step 32: If everything goes smoothly and the build is successful, you will receive an ipa file that can be downloaded to the device, for example, using iTunes. Add ipa to iTunes (or put it in a folder to other applications on the disk, and he will see it himself). Connect the device to the computer, on the Apps tab, select your application from the list and click Install. It remains to synchronize your device and the application will be installed on the device.

Step 33: As an alternative method of launching applications on devices (you can run simultaneously on several), in the editor, in the right part of the menu, click on the arrow next to the Launch button and select from the list something like All_iOS_On_YourPC , and then click on the Launch button. The project will start packing and installation on the connected devices (Mac is also included in the work).

Conclusion


That's all. Your workplace is ready to create iOS projects on UE4 straight from your Windows PC. In conclusion, I note that this method works only with code-based projects. However, you can easily turn any Blueprint project into code-based by simply adding an empty code file to it: in the editor, click File -> Add Code To Project. Thus, the project will become code-based and will normally be assembled by the above method.

At the moment, the method has been tested on the following engine versions: 4.2.x, 4.3

Source: https://habr.com/ru/post/227685/


All Articles