Original Discord Post by .eduhalfen | 2024-07-30 22:03:47
Hello!
I am testing Convai in Unity but the build in Unity failes.
Gives this error message:
Assets/Convai/Scripts/iOSBuild.cs(5,19): error CS0234: The type or namespace name ‘Callbacks’ does not exist in the namespace ‘UnityEditor’ (are you missing an assembly reference?)
I saw that it was missing a file (libgrpc.a) that was in another folder, I moved but It was not succesful.
Embedded Content: Building for iOS/iPadOS | API Docs
This guide will walk you through the process of installing Convai-powered Unity applications on iOS and iPadOS devices.
Link: Building for iOS/iPadOS | Documentation
//#if UNITY_EDITOR && UNITY_IOS
using System.IO;
using UnityEngine;
using UnityEditor;
using UnityEditor.Callbacks;
using UnityEditor.iOS.Xcode;
public class iOSBuild : 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
#if UNITY_EDITOR && UNITY_IOS
using System.IO;
using UnityEngine;
using UnityEditor;
using UnityEditor.Callbacks;
using UnityEditor.iOS.Xcode;
public class iOSBuild : 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