I updated the ironSource Unity SDK through the ironSource integration manager in Unity and after that my iOS builds started to fail on Unity Cloud Build with the following two error messages:
ERROR: iOS framework addition failed due to a CocoaPods installation failure. This will will likely result in an non-functional Xcode project.
Libraries/IronSource/Plugins/iOS/iOSBridge.h:10:9: ‘IronSource/IronSource.h’ file not found
Does anyone now if it is possible to get the CocoaPods installation to work on Unity Cloud Build?
error: Building for iOS, but the linked framework ‘IronSource.framework’ was built for iOS Simulator. (in target ‘UnityFramework’ from project ‘Unity-iPhone’)
I actually managed to build the application by removing the folder Assets/Plugins/iOS/IronSource.xcframework/ios-i386_x86_64-simulator. Is there any way to keep that folder but still getting the application to build on Unity Cloud Build? When building locally I would ideally want to keep this folder.
I’ve had some success running cocoapods before but I’ve always ran it manually from a post build script.
You would normally have a ‘podfile’ containing the pods you want installed. For example, something like this one below. Call it ‘podfile’ and put it in your Editor folder so it can get copied by the script below.
platform :ios, '11.0'
target 'UnityFramework' do
pod 'IronSourceSDK','7.2.1.2'
end
In addition to that you would have a script within an Editor folder that would run after the build, this will install the pod files manually. I’ve put an example below which is hacked from bits I have so it’s not been tested but it should work.
You’ll notice that on cloud build it calls ‘pod’ rather than ‘/usr/local/bin/pod’. This is important because it won’t work otherwise, from what I can gather the cloud build runs in a type of virtual machine which is why the path is different. You might find that the ironsource sdk has a call to ‘usr/local/bin/pod’ that just needs updating for the cloud build.
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using ICSharpCode.SharpZipLib.Core;
using ICSharpCode.SharpZipLib.Zip;
using UnityEditor;
using UnityEditor.Build;
using UnityEditor.Build.Reporting;
using UnityEditor.Callbacks;
using Debug = UnityEngine.Debug;
#if UNITY_IOS
using UnityEditor.iOS.Xcode;
#endif
#if UNITY_IOS
public static class PodsPostProcessor
{
[PostProcessBuild]
static void OnPostProcessGenPodfile(BuildTarget buildTarget, string pathToBuiltProject)
{
if (buildTarget != BuildTarget.iOS)
return;
// update the Xcode project file
var projPath = Path.Combine(pathToBuiltProject, "Unity-iPhone.xcodeproj/project.pbxproj");
var project = new UnityEditor.iOS.Xcode.PBXProject();
project.ReadFromFile(projPath);
// grab our Podfile and copy it into the Xcode project folder and open get the correct GUID based on Unity version
var target = project.GetUnityFrameworkTargetGuid();
File.Copy("Assets/Editor/Podfile", Path.Combine(pathToBuiltProject, "Podfile"), true);
// optionally update some project settings
//project.AddBuildProperty(target, "CLANG_ENABLE_MODULES", "YES");
File.WriteAllText(projPath, project.WriteToString());
#if UNITY_CLOUD_BUILD
Debug.Log("PostProcessor running cocoapods on Unity CloudBuild");
var proc = new Process
{
StartInfo =
{
WorkingDirectory = pathToBuiltProject,
FileName = "pod",
Arguments = "install --repo-update",
UseShellExecute = false,
RedirectStandardOutput = true,
CreateNoWindow = true
}
};
#else
Debug.Log("PostProcessor running cocoapods");
var proc = new Process
{
StartInfo =
{
WorkingDirectory = pathToBuiltProject,
FileName = "/usr/local/bin/pod",
Arguments = "install --repo-update",
UseShellExecute = false,
RedirectStandardOutput = true,
CreateNoWindow = true
}
};
#endif
proc.Start();
while (!proc.StandardOutput.EndOfStream)
{
var line = proc.StandardOutput.ReadLine();
Debug.Log(line);
}
}
}
#endif
Hey you seems to know some ways to make Ironsource work.
I managed to make it work on Android and iOS using cloud build but when I add the unity adapter it fails during my app startup only in iOS.
Some error in the console told me that it missed a switft libraries so I tried a post process build
var project = new PBXProject();
var path = PBXProject.GetPBXProjectPath(buildPath);
project.ReadFromFile(path);
var target = project.GetUnityMainTargetGuid();
project.SetBuildProperty(target,"EMBEDDED_CONTENT_CONTAINS_SWIFT","YES");
// ??? project.SetBuildProperty(target,"ENABLE_BITCODE","NO");
project.SetBuildProperty(target,"ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES","YES");
project.SetBuildProperty(target,"SWIFT_VERSION","5.0");
project.WriteToFile(path);
Debug.Log("EMBEDDED_CONTENT_CONTAINS_SWIFT SET TO YES");
but no success so far, it’s infuriating that it only fails on ios