Skip to content
TREN
Atlıhan Harita

LCC for Unity User Manual · Feature Development Guide

iOS Device Compilation and Packaging Development Guide

Chapter 15.21 / 17Manual version v2.3.0English

Background

LCC Unity SDK is published in the form of precompiled DLLs. Because the iOS platform requires native plugins to be linked as static libraries (__Internal) rather than dynamically loaded (dlopen), you need to complete the additional configuration steps described in this document before building an iOS application. There is a fundamental difference in native plugin loading mechanisms between iOS and other platforms; other platforms (Windows, macOS, Android, Linux) require no additional operations.

This SDK uses "libwebp" as the P/Invoke target when compiled into a DLL. The SDK's built-in Editor/RewriteWebpDllImport.cs script automatically rewrites it to "__Internal" during iOS builds, ensuring that IL2CPP generates the correct direct symbol calls.

Note:

When compiling an iOS device application, first rename Editor/RewriteWebpDllImport.txt in the SDK package to Editor/RewriteWebpDllImport.cs for the script to take effect. Alternatively, directly change the script's suffix in the SDK package and copy it into the project's Assets/Editor/ directory.

Prerequisites

The RewriteWebpDllImport.cs script uses the IL rewriting library Mono.Cecil during the build, so you need to add it as a dependency to the project first. There are two ways; choose either one.

Open the Unity menu bar Window → Package Manager, click the + button in the top-left corner, choose Add package by name..., enter the name com.unity.nuget.mono-cecil, enter the version 1.11.5, click Add, and wait for the Package Manager to finish installing, as shown below.

Add the Mono.Cecil dependency by name in the Package Manager

Add com.unity.nuget.mono-cecil by name in the Package Manager

Method 2: Manually edit manifest.json

Directly edit the project's Packages/manifest.json and add a line under dependencies:

{
  "dependencies": {
    "com.unity.nuget.mono-cecil": "1.11.5"
  }
}

After saving, switch back to Unity; the Editor will automatically resolve and install the dependency.

Build Workflow

After completing the prerequisite configuration, follow the standard iOS build workflow; RewriteWebpDllImport will intervene automatically during the build.

  1. Rename Editor/RewriteWebpDllImport.txt to Editor/RewriteWebpDllImport.cs (if not already renamed).
  2. In the Unity menu bar, select File → Build Settings, select iOS from the platform list, and click Switch Platform.
  3. Click Build (or Build And Run), select an output directory, and generate the Xcode project.
  4. During the build, the script automatically rewrites all DllImport entries in the SDK targeting "libwebp" to "__Internal". After a successful build, the Console outputs a log similar to:
[RewriteWebpDllImport] Rewrote 77 P/Invoke entries from "libwebp" to "__Internal".
  1. Open the generated project with Xcode, and in the target's Build Phases → Link Binary With Libraries, confirm that libwebp.a, libwebpdemux.a, and libsharpyuv.a are linked.
  2. Connect the iOS device, sign and run in Xcode.

Note:

If the [RewriteWebpDllImport] log does not appear in the Console, it usually means the script did not take effect — confirm that the file suffix has been changed from .txt to .cs and that the Mono.Cecil dependency is correctly installed.

Troubleshooting

Error messageCauseSolution
Unable to load DLL 'libwebp'The script did not take effect, and DllImport still points to the dynamic library nameConfirm that RewriteWebpDllImport.txt has been renamed to .cs, rebuild, and check the Console log
Cannot find LCCSDK.dll in staging areaThe SDK's main DLL was not found during the build, and the rewrite target is missingConfirm that the SDK is correctly imported into the project and the DLL is not excluded from iOS by Exclude Platform
Mono.Cecil-related compilation errors (cannot find the Mono.Cecil namespace)Not installed or version mismatchAdd com.unity.nuget.mono-cecil@1.11.5 according to "Prerequisites" and wait for the compiler to re-resolve

Notes

  • It is recommended to use Unity 2022.3 LTS or higher (including Unity 6); compatibility with Mono.Cecil and IL2CPP cannot be guaranteed on overly old versions.
  • If you need to run on the iOS Simulator, confirm that the linked static library contains the arm64-simulator architecture slice, otherwise the simulator cannot link.
  • The above configuration only affects the iOS platform. The build workflows of Windows, macOS, Android, and Linux are not affected at all, and there is no need to rename the script or add the Mono.Cecil dependency.

This chapter is from the official XGRIDS user manual. Official source (opens in a new tab) · Updated:

XGRIDS Türkiye

We're With You During Setup and in the Field

Atlıhan Harita provides training and technical support for device setup, firmware updates, software use, and field applications. Send us your question and our specialist will get back to you.

+90 216 546 0804