Structure of a Unity XCode Project
Inside the iOS build process
Editor Based Building and Running
The iPhone/iPad application build process is a two step process:
- XCode project is generated by Unity with all the required libraries, precompiled .NET code and serialized assets.
- XCode project is built by XCode and deployed and run on the actual device.
When “Build” is hit on “Build settings” dialog only the first step is accomplished. Hitting “Build and Run” performs both steps.
If in the project save dialog the user selects an already existing folder an alert is displayed. Currently there are two XCode project generation modes to select:
-
replace - all the files from target folder are removed and the new content is generated
-
append - the “Data”, “Libraries” and project root folder are cleaned and filled with newly generated content. The XCode project file is updated according to the latest Unity project changes. XCode project “Classes” subfolder could be considered as safe place to place custom native code, but making regular backups is recommended. Append mode is supported only for the existing XCode projects generated with the same Unity iOS version.
If Cmd+B is hit then the automatic build and run process is invoked and the latest used folder is assumed as the build target. In this case append mode is assumed as default.
Note: Step one above can be performed on a PC or a Mac. Only a Mac can perform Step two. This means to get a Unity project running on an iDevice you will need to have a Mac.
Command Line Building
Once Unity has been used to build the XCode project it is possible to perform the build and run from the command line. After the editor has built the XCode project do the following from the terminal:
unity$ xcodebuild test -destination "platform=iOS,id=400d20d00baf8d4997b47be0416cf5c44dd2d3bc" -scheme Unity-iPhone
Note that 400d20d00baf8d4997b47be0416cf5c44dd2d3bc in the command line example above is the ID of the iDevice that will run the project. You will need to determine your device ID using the Window > Devices menu in XCode.
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Is something described here not working as you expect it to? It might be a Known Issue. Please check with the Issue Tracker at issuetracker.unity3d.com.
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thanks for helping to make the Unity documentation better!
Structure of a Unity XCode Project