UnityBuildKit is a command line tool that embeds a Unity project into an iOS application. Both the Xcode and Unity project are automatically created, configured, and linked for immediate use after successful generation.
UnityBuildKit requires Xcode 9, Swift 4, and Unity
git clone https://github.com/handsomecode/UnityBuildKit
cd UnityBuildKit
make
.package(url: "https://github.com/handsomecode/UnityBuildKit", from: "1.0.0"),
Currently, Unity needs to be closed for this process to begin.
- Create a top-level folder and navigate to it. This folder will contain all information about the Xcode and Unity projects. (Note: By default, the name of this folder will be the name of the Xcode and Unity projects.)
mkdir ExampleProject
cd ExampleProject
- Create a configuration file named
ubconfig.json
{
"project_name": "", // Leaving this empty uses folder name by default
"bundle_id": "is.handsome.UnityBuildKit",
"unity_path": "<path_to_unity_app>", // "/Applications/Unity/Unity.app/Contents/MacOS/Unity"
"unity_version": "2017.1.1f1",
"unity_scene_name": "" // Leaving this empty uses folder name by default
}
- Run
$ UnityBuildKit generate
- Once generation is completed, open the Xcode project. Using the Build Scheme drop down menu, select Edit Scheme to edit your project's scheme (the scheme should be the same name as your project). Select the Run action then the Options tab. In the middle of the window, you will see
Metal API Validationwith a set of options in a drop down menu. Change the current option toDisabled, as seen below:
(Note: if you do not see the option for Metal API Validation, verify your run destination is a physical device of set to Generic iOS Device)
-
The generation script sets up the Unity project to build for the Device SDK. These means that, if building for a simulator, there is a high probability that you will encounter build and linker errors in Xcode. Change the run destination to a physical device and the errors should go away.
-
If building for a physical device, do not forget to set up your code signing.
After making updates to your Unity project, you'll need to refresh the files linked with the Xcode project. Currently, Unity needs to be closed for this process to begin.
- Navigate to the top-level folder
cd ExampleProject
- Run
UnityBuildKit refresh
- 2107.1.f1
This tool is built using:
and the wonderful dependencies they bring with them.
Inspiration for building UnityBuildKit came after running into several problems while trying to manually do this process and reading over a github issue trying to resolve those problems.
UnityBuildKit is licensed under the MIT license. See LICENSE for more info.