Version: Unity 6.6 Alpha (6000.6)
Language : English
Initialization paths for native iOS plug-ins
Integrating Unity into native iOS applications

Unity native plug-in example for iOS

Use the native plug-inA set of code created outside of Unity that creates functionality in Unity. There are two kinds of plug-ins you can use in Unity: Managed plug-ins (managed .NET assemblies created with tools like Visual Studio) and Native plug-ins (platform-specific native code libraries). More info
See in Glossary
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.5 or later, and works on both device and simulator SDKs.

The repository contains two native plug-insA platform-specific native code library that is created outside of Unity for use in Unity. Allows you can access features like OS calls and third-party code libraries that would otherwise not be available to Unity. More info
See in Glossary
that illustrate different integration strategies:

  • Objective-C: A deep integration with the Unity runtime that uses class loading (+load, +initialize) and direct AppController subclassing.
  • Swift: A lighter integration that uses Swift-native patterns and the Unity Swift API.

Both implementations expose an identical C API, ensuring C# scriptsA piece of code that allows you to create your own Components, trigger game events, modify Component properties over time and respond to user input in any way you like. More info
See in Glossary
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).

Additional resources

Initialization paths for native iOS plug-ins
Integrating Unity into native iOS applications