I have started using some UTF8 encoding in my Unity project and now when I build for iOS, I need the libicucore library in order for the project to link.
When I build locally I just add the libicucore.tbd file to xcode and the build succeeds.
I am looking for a way to do it in cloud build.
Already have a post process script that I use, and I have seen the docs regarding adding files to the PBXProject instance, but I am not sure how to do it with cloud build.
Where should I put the file? How do I add it so it works with cloud build?
Would love to see some up-to-date example, I am using Unity 5.6.2
Thanks
Here you go, add this file to an Editor folder:
#if UNITY_IOS
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEditor;
using UnityEditor.Callbacks;
using UnityEditor.iOS.Xcode;
using UnityEngine;
using NSubstitute.Routing.AutoValues;
using System.Text;
/// <summary>
/// Helper editor class for updating the generated XCode project's Info.plist file.
/// </summary>
public static class XcodeProcessor
{
[PostProcessBuild]
public static void ProcessBuild(BuildTarget buildTarget, string pathToBuiltProject)
{
if (buildTarget != BuildTarget.iOS)
{
return;
}
UpdateXcodeProject(pathToBuiltProject);
}
private static void UpdateXcodeProject (string pathToBuiltProject)
{
string projPath = pathToBuiltProject + "/Unity-iPhone.xcodeproj/project.pbxproj";
PBXProject proj = new PBXProject();
string projString = File.ReadAllText(projPath);
proj.ReadFromFile(projPath);
string targetGUID = proj.TargetGuidByName("Unity-iPhone");
proj.AddFileToBuild(targetGUID, proj.AddFile("usr/lib/libicucore.tbd", "Frameworks/libicucore.tbd", PBXSourceTree.Sdk));
proj.AddFileToBuild(targetGUID, proj.AddFile("usr/lib/libicucore.tbd", "Frameworks/libicucore.tbd", PBXSourceTree.Build));
File.WriteAllText(projPath, projString);
}
}
#endif
Thanks Lior
I managed to solve this in almost the same way, I just added the dylib file directly and not the tbd file, and using PBXSourceTree.Source instead.
So my code looks like:
proj.AddFileToBuild (targetGUID, proj.AddFile ("Frameworks/libicucore.dylib",
"Frameworks/libicucore.dylib", PBXSourceTree.Source));
I then added the dylib file to my project since I was not sure it is available on the cloud build machine.
Anyways, thanks for your reply