Version: Unity 6.6 Alpha (6000.6)
Language : English
Source and binary forms of native iOS plug-ins
Initialization paths for native iOS plug-ins

Conditional compilation behavior for native iOS plug-ins

Learn about the conditions you can check at different stages of build and runtime to create a generic 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
that works across different targets.

Use conditional logic to create a generic plug-in that works across different targets. You can add checks in both native and C# code at different stages of the build and runtime process.

The following table outlines the conditions you can check at each stage:

Build stage Conditions and usage
Xcode project generation Automatic plug-in integration:

When using the plug-in Inspector, you can use conditions to check for the Platform, SDK version, Architecture, and Project type.

Note: The plug-in Inspector window can’t filter on the current Unity version.

Manual plug-in file injection at post process with the PBXProject API:

Use PostProcessBuildAttribute with the PBXProject API to add plug-ins based on Unity versions. You can check for:
Xcode project compilation In native code (Swift or Objective-C), you can check for:
Application runtime In native code, Swift or Objective-C, you can check for: In a C# managed script, you can check for:

You can use preprocessor directives, such as #if, in both Swift and Objective-C to adjust behavior based on the target platform, architecture, or SDK version.

Unity’s generated Xcode project can be one of two types: Swift or Objective-C. To distinguish between these types in your native code, use the UNITY_XCODE_PROJECT_TYPE_SWIFT preprocessor macro.

Additional resources

Source and binary forms of native iOS plug-ins
Initialization paths for native iOS plug-ins