How to compile Apple Unity plugins without a Mac

Back




Intro

I wanted to integrate Apple GameKit plugin into my Unity game for Android & iOS. I don't have a mac and couldn't build the plugins easily. Also did not find anywhere online the plugin tarballs or any solution to the problem.

Therefore I built the apple unity plugins I needed. You can download them, or follow this guide to build them by yourself if you don't trust me or need other plugins.



Download the Apple Core, GameKit Unity plugins:

Apple.Core (3.1.8)
Apple.GameKit (3.0.2)

I did not sign the plugins so Unity will shout and give a warning when you try to import them into your editor.
Unity game engine unsigned package warning
Unity game engine import package from tarball
Just take them, open unity, and import those tarballs via the package manager. Again remember - it will show a warning because they are unsigned, but it's normal.


How to build Unity Apple GameKit & Core plugins by yourself without a macbook?

If you don't trust me or want different plugins, you should build them by yourself. In this guide I suppose you have the basic knowledge a software developer possesses and familiar with basic tools.

Among the tools I suppose you know: Python, Bash, Linux, Unity, Git.

Also please watch ONLY THE CLOUD BUILD USAGE PART (9:40 - 18:20) in the following great tutorial of Unity Cloud Build without a Mac and any tutorial of Uploading Files to Google Drive with Python. I will focus only on the parts not found yet on the internet so please do your homework.

Regarding the cloud build tutorial, it explains how to upload your project to the app store connect. We don't need app store connect account to build the packages. The tutorial just teaches you to use the unity cloud build well and it's the one I followed. The whole building and fetching apple unityplugins magic happens ONLY in the pre-build script of the cloud build, so after its execution finished according to logs you can cancel the build and fetch your tarballs. You don't need to wait for the actual unity build to execute.

Let's begin.



Gitignore

Go to your Unity project's root folder. Usually you backup via git only Assets, Packages, Project Settings folders. Make your project's root gitignore looks like in the image.
Game root folder gitignore file

AppleGameKitPlugins is the cloned folder from the Apple Unity plugins github repo. BuildScripts will contain the files we need to build the tarballs and fetch them from the remote machine. LocalPackages is to save the built tarballs inside your unity project using git.



My Specs

Unity DevOps cloud build settings configuration
The following is my setup. Inside unity my target minimum iOS version is 16, other stuff like Unity version, Xcode I compile with is in the image.


Setup Build Scripts

That's how my unity project's root looks like. The post_build.sh script is the script from the unity cloud build youtube tutorial I attached before, so it's irrelevant. The part we will dive into is CompileApplePlugins folder contents, that contains the whole logic.
unity project root filesystem
Setup unity pre build script
Here is how you should setup the pre-build script in your unity cloud build configuration.


Fetch the Apple Unity Plugins code

Simply cloning the repository is not enough. Because the main branch is made to be compiled with the latest Xcode version, and we use Xcode 16.4 in the build settings, the build will fail because of missing references.

You should find the correct git tag that you need and copy it into your project. In my case of Xcode 16.4, tag GameKit-3.0.2 was built successfully.
unityplugins apple github tags
GameKit unity plugins apple tag matching Xcode 16.4
Download the file with the apple unityplugins source code, extract it and put in your project's root folder. Delete all plugins you don't plan to compile and .gitignore files inside the hierarchy. Of course you need to commit the apple unityplugins content so the remote cloud mac can execute the build.


The Build Scripts

Download an archive of the BuildScripts and put it inside your project's folder, as in the image of my unity project root hierarchy. Let's go over what happens.

We give permission to execute apple script that fails otherwise. We run the build command to create files for iOS platform, Release only, Core and GameKit plugins. We create some logs of validation whether tarballs created successfully. We install python packages and execute the python script.
Compile plugins apple bash script
Apple build.py script flags
You may customize the script, the variables, and especially the build command to fit your needs. To check the build options of the command you can view the Build script docs. Just note that this documentation seems somewhat outdated and some flags do not exist despite them being in the docs, so better check the code of build.py file directly.
Now the python script. It just uploads the previously built tarballs to your Google Drive. You need to paste your drive_service_account.json file into CompileApplePlugins folder, as you have seen in the image before. Also you need to paste the folder ID you want to upload the tarballs to in the python script, into DRIVE_UPLOAD_FOLDER_ID variable. The folder ID can be found in the address bar when you open the drive folder on the web. That's why asked to watch Google Drive with python tutorial before.
Python script upload unityplugins to google drive


The Execution

Packed tarball unity apple plugins names cloud build logs
Another important point: you may see in the scripts hard coded expected tarballs paths. How to know their names to input to the scripts? you can modify the script to be smarter, or you can wait for the unity cloud build logs to tell you the file names of the tarballs (as I did). Search in the logs for the string "Packing plug-in".

Now, what do we have to do to gain the apple unityplugins tarballs? Let's go over everything again.

You should have already: cloned the correct apple unity plugins repo, pasted the BuildScripts, inserted your own drive_service_account.json file, modified compile-apple-plugins.bash variables & build command to match your needs. Modified upload_tarballs.py to contain your own drive folder id and variables.

Just run the cloud build and monitor the logs. After you see the final log of the bash script you can cancel the cloud build and check the logs between the first and the last bash script log, and see if all steps executed successfully or there were failures. If everything was successful, you should find the compiled tarballs in your Google Drive folder.
Google Drive apple plugins results


Final Notes

Will write here some additional points you should keep in mind.

First, you can use any unity project for it. An empty one, the one of your main game, whatever you want. I did it inside my game's project because it's easier for me.

Second, you are unlikely to succeed on your first build. You will definitely encounter issues. Investigate the cause in the logs and tweak the files to get closer to your destination. AI might help.

You will succeed
Read all the points carefully as misreading something may cause you to spend time debugging. Common issues that may occur - you did not set up the scripts correctly, you copied the main repository instead of the one matching your Xcode, you did not configure paths of scripts correctly, you did not push your files via git.

And again, our magic happens in the pre-build script. You can cancel the builds to save some money after the script execution finished.

Some may point out that there is this Unity build automation artifacts API. Initially I tried to use it instead of Google Drive but it is hard and not documented well. After spending too much time debugging errors decided that it's not worth the time and decided to move to the drive solution. If you have other methods you prefer such as AWS S3 you may of course use it instead of the google drive solution.

Feel free to contact me if you have any questions or issues, I might have already encountered them.



Back