Use the native plug-in example to understand how to develop a plug-in with Swift or Objective-C.
The Unity native plug-in example for Apple platforms project, hosted on Unity GitHub, demonstrates how to integrate native Objective-C and Swift code with Unity. This example shows integrations for Apple platforms, including iOS, tvOS, and visionOS. It highlights two different native implementations that share a single, unified C# API, allowing you to change the native back end without modifying your managed code.
The project is compatible with Unity 6000.0 or later, and works on both device and simulator SDKs.
Note: The Swift Xcode project type and the Unity Swift API is available from Unity 6000.5 and later. For more information, refer to Swift Xcode project type for iOS and tvOS.
The repository contains two native plug-ins that illustrate different integration strategies:
+load, +initialize) and direct AppController subclassing.Both implementations expose an identical C API, ensuring C# scripts can work with either plug-in without modification. Demonstrated techniques include different initialization methods, singleton patterns, UnitySendMessage callbacks, and handling data between managed and native code.
For the complete source code and technical details, refer to Unity native plug-in example for Apple platforms (Unity GitHub).