Ios build failes in Unity

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.

Reply by k3kalinix | 2024-07-30 22:23:28

Hello <@1110706174573154384>,
Could you please show me the iosbuild.cs

Reply by k3kalinix | 2024-07-30 22:24:03

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

Reply by k3kalinix | 2024-07-30 22:24:14

Make sure to follow the documentation.

Reply by .eduhalfen | 2024-07-30 23:10:01

I followed it. I used the step 4 but I think it didnt install everything. The files: libgrpc_csharp_ext.a and libgrpc.a were in wrong folder

Reply by .eduhalfen | 2024-07-30 23:10:21

Is it possible restart the process?

Reply by k3kalinix | 2024-07-31 01:22:53

Please show me the iosbuild.cs

Reply by .eduhalfen | 2024-07-31 12:17:44

//#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

Reply by k3kalinix | 2024-07-31 12:18:01

#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

Reply by k3kalinix | 2024-07-31 12:18:04

Try this.

Reply by .eduhalfen | 2024-07-31 12:26:16

It worked!!!
Thaks a lot!!

This conversation happened on the Convai Discord Server, so this post will be closed.