Ensure that your Unity project contains an Assets/link.xml file with the following content to prevent potential FileNotFoundException errors related to the libgrpc_csharp_ext.x64.dylib file:
Create Assets/Scripts/BuildIos.cs script in your Unity project. This script should be added to a game object within your scenes and will automate steps 2 and 3 during the post-build process:
#if UNITY_EDITOR && UNITY_IOS
using System.IO;
using UnityEngine;
using UnityEditor;
using UnityEditor.Callbacks;
using UnityEditor.iOS.Xcode;
public class BuildIos : MonoBehaviour
{
[PostProcessBuild]
public static void OnPostProcessBuild(BuildTarget target, string path)
{
var projectPath = PBXProject.GetPBXProjectPath(path);
var project = new PBXProject();
project.ReadFromString(File.ReadAllText(projectPath)); #if UNITY_2019_3_OR_NEWER
var targetGuid = project.GetUnityFrameworkTargetGuid(); #else
var targetGuid = project.TargetGuidByName(PBXProject.GetUnityTargetName()); #endif
project.AddFrameworkToProject(targetGuid, “libz.tbd”, false);
project.SetBuildProperty(targetGuid, “ENABLE_BITCODE”, “NO”);
File.WriteAllText(projectPath, project.WriteToString());
}
} #endif