Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Bug ironSource Unity SDK 7.2.1.2 install fails on Unity Cloud Build

Discussion in 'Unity Build Automation' started by ogglynator, May 12, 2022.

  1. ogglynator

    ogglynator

    Joined:
    May 2, 2014
    Posts:
    12
    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?

    I tried to install ironSource through the manual integration described here: https://developers.is.com/ironsource-mobile/unity/unity-plugin/#step-4.

    That worked better, but I then got this error:

    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.
     
  2. tonemcbride

    tonemcbride

    Joined:
    Sep 7, 2010
    Posts:
    1,077
    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.

    Code (CSharp):
    1. platform :ios, '11.0'
    2.  
    3. target 'UnityFramework' do
    4.     pod 'IronSourceSDK','7.2.1.2'
    5. 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.

    Code (CSharp):
    1. using System;
    2. using System.Diagnostics;
    3. using System.IO;
    4. using System.Linq;
    5. using ICSharpCode.SharpZipLib.Core;
    6. using ICSharpCode.SharpZipLib.Zip;
    7. using UnityEditor;
    8. using UnityEditor.Build;
    9. using UnityEditor.Build.Reporting;
    10. using UnityEditor.Callbacks;
    11. using Debug = UnityEngine.Debug;
    12.  
    13. #if UNITY_IOS
    14. using UnityEditor.iOS.Xcode;
    15. #endif
    16.  
    17. #if UNITY_IOS
    18. public static class PodsPostProcessor
    19. {
    20.     [PostProcessBuild]
    21.     static void OnPostProcessGenPodfile(BuildTarget buildTarget, string pathToBuiltProject)
    22.     {
    23.         if (buildTarget != BuildTarget.iOS)
    24.             return;
    25.  
    26.         // update the Xcode project file
    27.         var projPath = Path.Combine(pathToBuiltProject, "Unity-iPhone.xcodeproj/project.pbxproj");
    28.         var project = new UnityEditor.iOS.Xcode.PBXProject();
    29.         project.ReadFromFile(projPath);
    30.  
    31.         // grab our Podfile and copy it into the Xcode project folder and open get the correct GUID based on Unity version
    32.         var target = project.GetUnityFrameworkTargetGuid();
    33.         File.Copy("Assets/Editor/Podfile", Path.Combine(pathToBuiltProject, "Podfile"), true);
    34.  
    35.         // optionally update some project settings
    36.         //project.AddBuildProperty(target, "CLANG_ENABLE_MODULES", "YES");
    37.         File.WriteAllText(projPath, project.WriteToString());
    38.  
    39.         #if UNITY_CLOUD_BUILD
    40.         Debug.Log("PostProcessor running cocoapods on Unity CloudBuild");
    41.         var proc = new Process
    42.         {
    43.             StartInfo =
    44.             {
    45.                 WorkingDirectory = pathToBuiltProject,
    46.                 FileName = "pod",
    47.                 Arguments = "install --repo-update",
    48.                 UseShellExecute = false,
    49.                 RedirectStandardOutput = true,
    50.                 CreateNoWindow = true
    51.             }
    52.         };
    53.         #else
    54.         Debug.Log("PostProcessor running cocoapods");
    55.         var proc = new Process
    56.         {
    57.             StartInfo =
    58.             {
    59.                 WorkingDirectory = pathToBuiltProject,
    60.                 FileName = "/usr/local/bin/pod",
    61.                 Arguments = "install --repo-update",
    62.                 UseShellExecute = false,
    63.                 RedirectStandardOutput = true,
    64.                 CreateNoWindow = true
    65.             }
    66.         };
    67.         #endif        
    68.         proc.Start();
    69.         while (!proc.StandardOutput.EndOfStream)
    70.         {
    71.             var line = proc.StandardOutput.ReadLine();
    72.             Debug.Log(line);
    73.         }
    74.     }
    75. }
    76. #endif
    77.  
     
  3. rbitard

    rbitard

    Joined:
    Jan 11, 2022
    Posts:
    189
    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
    Code (CSharp):
    1.             var project = new PBXProject();
    2.             var path = PBXProject.GetPBXProjectPath(buildPath);
    3.             project.ReadFromFile(path);
    4.             var target = project.GetUnityMainTargetGuid();
    5.             project.SetBuildProperty(target,"EMBEDDED_CONTENT_CONTAINS_SWIFT","YES");
    6.             // ??? project.SetBuildProperty(target,"ENABLE_BITCODE","NO");
    7.             project.SetBuildProperty(target,"ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES","YES");
    8.             project.SetBuildProperty(target,"SWIFT_VERSION","5.0");
    9.             project.WriteToFile(path);
    10.             Debug.Log("EMBEDDED_CONTENT_CONTAINS_SWIFT SET TO YES");
    11.  
    but no success so far, it's infuriating that it only fails on ios :/
     
  4. tonemcbride

    tonemcbride

    Joined:
    Sep 7, 2010
    Posts:
    1,077
    Sorry, I've not worked on that for ages so I'm not sure I would be much help. What is the 'unity adapter'? Is that part of the ironsource system?
     
  5. rbitard

    rbitard

    Joined:
    Jan 11, 2022
    Posts:
    189
    it's an adapter you install to get access to more sources
    upload_2023-4-2_16-38-17.png