Unity native plug-in example for iOS
Use the native plug-in example to understand how to develop a plug-in with Swift or Objective-C.
Read time 1 minuteLast updated 19 days ago
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.
The repository contains two native plug-ins that illustrate different integration strategies:
- Objective-C: A deep integration with the Unity runtime that uses class loading (,
+load) and direct+initializesubclassing.AppController - Swift: A lighter integration that uses Swift-native patterns and the Unity Swift API.
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, callbacks, and handling data between managed and native code.
UnitySendMessageFor the complete source code and technical details, refer to Unity native plug-in example for Apple platforms (Unity GitHub).
Additional resources
- Unity native plug-in example for Apple platforms (Unity GitHub)