Version: Unity 6.6 Alpha (6000.6)
Language : English
Create callbacks from native code
Source and binary forms of native iOS plug-ins

Configure a plug-in for iOS with the Inspector window

Use the InspectorA Unity window that displays information about the currently selected GameObject, asset or project settings, allowing you to inspect and edit the values. More info
See in Glossary
window to add native plug-insA 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
and their files to the generated Xcode project.

Select a plug-in in the Project window to open its settings in the Inspector window. If the compatibility settings match your build target, Unity includes the plug-in in the generated Xcode project. For general plug-in configuration, refer to Import and configure plug-ins.

Unity supports 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
for the following file types:

  • Source files: .m, .mm, .c, .cpp, .h, and .swift.
  • Binary files: .bundle, .framework, .xcframework, .a, and .dylib.

When you place files with these extensions in the Assets/Plugins/iOS folder, Unity automatically enables them for the iOS platform.

During the build process, Unity copies these files into the generated Xcode project. Xcode then compiles or links to them in the final application. To configure compatibility for a specific plug-in, select it in the Project window to open its settings in the Inspector window.

Warning: Files copied to the generated Xcode project aren’t linked to their original versions in your Unity project. If you change these files in Xcode, you must manually copy them back into your Unity project. Otherwise, Unity overwrites your changes the next time you build the project.

Note: To support different project types in your native source code plug-in, use conditional compilation. For more information, refer to Conditional compilation behavior for native iOS plug-ins. During the build, the compiler selects the appropriate code path based on the macros you define.

iOS settings

Use the following Inspector window settings to configure a native plug-in for iOS.

Framework dependencies

Specify the operating system frameworks that your native plug-in depends on. Unity adds these to the Link Binary With Libraries section of the UnityFramework target in the Xcode project.

CPU

Specify the CPU architecture that your plug-in supports. It’s recommended to support multiple architectures for broad compatibility. Unity provides ARM64 and x64 (Simulator) for testing.

Add to embedded binaries

Enable Add to Embedded Binaries to copy the plug-in into the final application package. This is required for:

  • Dynamically loaded libraries (.dylib).
  • Bundles and frameworks that contain dynamically loaded code.
  • Assets and resources that must be loaded at runtime.

Compile flags

Set compiler flags for Xcode to use when building the plug-in source. These appear in the Xcode project under UnityFramework > Build Phases > Compile Sources > your plug-in > Compiler Flags.

Xcode project type

Choose which Xcode project type the plug-in applies to. You can set the project type in iOS Player settingsSettings that let you set various player-specific options for the final game built by Unity. More info
See in Glossary
: Objective-C or Swift.

Additional resources

Create callbacks from native code
Source and binary forms of native iOS plug-ins