Version: Unity 6.5 (6000.5)
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 Inspector window to add native plug-ins 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-ins 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 settings: Objective-C or Swift.

Additional resources

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