Before we start building the project itself, we need to prepare by make a few changes to your phone settings.
Go into Settings > Battery and turn off Low Power Mode.
Return to the Settings main window and then navigate to Settings > General and set Auto-Lock to “Never”.
Return to your Unity project and open the Build Settings window by navigating to
File > Build Settings...
Make sure the current scene is included and that the platform is set to iOS.
If everything matches, click “Player Settings...” before building.
Inside of the PlayerSettings window, edit the Company Name, Product Name and Bundle Identifier fields.
Company Name:Either your company name of Apple Developer ID or the name associated with your Apple ID if you don’t have a developer account.
Product Name: “EndlessRunner”, the name of the app we are building/running.
Bundle Identifier: “com.CompanyName.ProductName”
These are the only fields we’ll have to edit in this window.
Return to your “Build Settings” window and click “Build”.
Another window will appear, Build iOS, will appear that asks for what name you’d like to save the build folder as and where on computer.
You can choose whatever name and location you like. In this example, I’ll save the build folder as “EndlessRunner” inside of my Unity project folder.
Once it’s done building, navigate to where the new folder is saved and open the Unity-iPhone.xcodeproj.
Connect your iPhone to the computer and select it in XCode as the device you would like to run on.
Set the build settings inside of XCode by clicking the Unity-iPhone project in the left menu.
Make sure Bundle Identifier is set and Team is set to your Apple ID/Developer account.
Also uncheck “Portrait” and “Upside Down” under Device Orientation.
After all the settings are set, click the “Run” button in the upper left corner. The project will then build and be installed on your device.
Once the installation is complete, you should be able to run the game directly on your phone!