ドキュメント

Unity Engine


User Manual

Script Reference

Unity Engine


Structure of a Unity Xcode Swift project type

Organization and layout of Unity Swift Xcode projects.
読み終わるまでの所要時間 6 分最終更新 5日前

When you build a Unity Xcode Swift project for the iOS platform, Unity creates a folder that contains an Xcode project. You need to build and sign this project before you deploy it on a device or distribute it on the App Store.
注
Use the Xcode project type Player setting to build an Objective-C or Swift Xcode project type. For information on the structure of a Unity Xcode project built with Objective-C, refer to Structure of a Unity Xcode Objective-C project type.
Every generated Unity iOS Xcode Swift project has the following structure and targets:

Unity iOS Xcode Swift project structure

注
This image is for reference purposes only. Your project structure might look different to this example image depending on the version of Unity you're using. Refer to Project structure for information on the project structure elements that remain unchanged across different versions.
注
A Unity Swift application is initialized from the MainApp/MainApp.swift file.
The Xcode project includes both the
.xcodeproj
project file and framework links that only appear in the Xcode project navigator. Apart from the default folders, you can create custom folders to add custom files as required.
For projects that use Swift, Unity generates the
.xcodeproj
file name from your Unity project name. It sanitizes the name by removing spaces, symbols, and other non-alphanumeric characters.
You can use
PBXProject.GetPBXProjectPath
to return the
xcodeproj
file path rather than using a hardcoded file name.
注
To modify a generated Xcode project, use Xcode.PBXProject.

Project targets

A Unity Xcode Swift project contains the following targets:

Target

Description

Unity-iPhoneA thin launcher part that runs the
UnityFramework
. It includes the
MainApp
folder and app representation data such as Launch Screens,
.xib
files, icons, data, and
Info.plist
files. The Unity-iPhone target has a single dependency on the
UnityFramework
target.

Note:
UnityFramework.framework
is linked with the main binary unlike an Objective-C project type.
UnityFrameworkThe target that produces the
UnityFramework.framework
bundle. It includes the Unity runtime, UnityFramework and Libraries folders, along with dependent frameworks and links the
UnityAPI
target. The
UnityFramework
folder includes a privacy manifest file (
PrivacyInfo.xcprivacy
), a consolidated privacy manifest file for the Unity runtime, Unity plug-ins, packages, and your project.
UnityAPIA static framework that produces the
UnityAPI.framework
bundle. It contains the Unity trampoline source code and exposes the public
UnityAPI
module (including the
UnityPlayer
API and the
UnityPluginInterface
headers) to native plug-ins. The
UnityFramework
target links this target.

Note: This target is generated only for the Swift project type. The Objective-C project type doesn't contain it.
GameAssemblyA container for your C# code translated as C++ code. To build it, Xcode uses the IL2CPP tool that Unity includes in every generated Xcode project. The build produces:

  • libGameAssembly.a
    : A static library that contains all the project’s managed code, cross-compiled to C++, and built for iOS.
  • il2cpp.a
    : A static library that contains the IL2CPP runtime code to support your managed code.
注
Use PBXProject.GetUnityFrameworkTargetGuid() to get the UnityFramework target GUID and PBXProject.GetUnityMainTargetGuid() to get the Unity-iPhone target GUID. Use PBXProject.GetUnityAPITargetGuid() to get the UnityAPI target GUID. This target exists only for the Swift project type. The method returns
null
for the Objective-C project type.

Project structure

When developing a Swift project type, Unity guarantees that certain parts of the generated Xcode project will remain the same during development. The following files and folders will be treated as a public API and will follow a standard deprecation process when any changes are made. For more information, refer to Swift project type API reference.

Project file structure

  • {projectName}.xcodeproj: The main Xcode project file in the root directory.
  • Data/: The folder that contains compiled Unity Engine content.
  • UnityFramework/Libraries/: The standard folder for library files added by plug-ins.
  • UnityFramework/Info.plist: The property list for the UnityFramework.
  • UnityFramework/PrivacyInfo.xcprivacy: The privacy manifest file required by Apple.
  • UnityAPI/UnityPluginInterface/: Contains headers available for plug-ins to import.

Data folder

This folder contains your application’s serialized assets and .NET
.dat
files. The
machine.config
file sets up various .NET services such as Security and WebRequest. By default, the Data folder’s Target Membership is the Unity-iPhone target, and Unity runtime searches for it in the mainBundle.
注
The contents of this folder are refreshed with every build. You shouldn’t make any changes to it.
注
On-Demand Resources are only supported when the Data folder is a part of the Application target and not a part of the UnityFramework target.

Data folder with the Target Membership set to Unity-iPhone

注
This image is for reference purposes only. Your project structure might look different to this example image depending on the version of Xcode you're using. Refer to Project structure for information on the project structure elements that will remain unchanged across different versions.

Frameworks folder

The Frameworks folder contains
UnityRuntime.framework
, the Unity Runtime static frameworks library for device and simulator.

Libraries folder

The contents of the Libraries folder are refreshed with every build. You shouldn’t make any changes to it.

MainApp folder

The
MainApp
folder contains the application’s
Info.plist
, icons and splash screens (.png files) in asset catalogs, launch screens, their XML Interface Builders (.xib files), and Storyboard files. Unity automatically manages these files. You can configure icons and launch screens in the Player settings window (menu: Edit >
Project Settings

?

> Player). Make sure the custom launch images that you create adhere to Apple’s Human Interface Guidelines.

Property list (.plist) file

The
Info.plist
file for the Unity-iPhone target is located at
MainApp/Info.plist
(accessed via
mainBundle
). You can manage it from Unity’s Player settings window (menu: Edit > Project Settings > Player > Other Settings > Identification). Unity updates this file rather than replacing it while building the Player. Don’t make changes to it unless you need to.
The
/UnityFramework/Info.plist
file, accessed via
bundleWithIdentifier:@"com.unity3d.framework"
, is a part of
UnityFramework
. You can keep project specific values in this file instead of the
Info.plist
file of the
mainBundle
. This makes sure that you can still get these values if
UnityFramework
is moved into another application, for example, when using Unity as a Library.
注
You can also manage the
Info.plist
file using the PlistDocument API. For more information, refer to PlistDocument.

Additional resources