Googleads-mobile-unity: Unity Cloud Build for iOS doesn't support cocoapods

Created on 4 Jan 2017  路  15Comments  路  Source: googleads/googleads-mobile-unity

Currently Unity Cloud Build doesn't support cocoapods.

'pod' command not found; unable to generate a usable Xcode project.

Is it possible to integrate the latest version of the plugin without using cocoapods at all?

Should I just add iOS Mobile Ads SDK to my project to solve the problem?

feature request blocked

Most helpful comment

Currently, the JarResolver library does not support Unity Cloud builds, but we are working to fill that gap in functionality. Look for an update on this soon.

All 15 comments

This plugin breaks Unity Cloud Build. We no longer get automated builds.

24106: [Unity] 'pod' command not found; unable to generate a usable Xcode project. You can install cocoapods with the Ruby gem package manager:
24107: [Unity]  > sudo gem install -n /usr/local/bin cocoapods
24108: [Unity]  > pod setup
24109: [Unity] UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
24110: [Unity] UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
24111: [Unity] UnityEngine.Logger:Log(LogType, Object)
24112: [Unity] UnityEngine.Debug:LogError(Object)
24113: [Unity] Google.IOSResolver:Log(String, Boolean, LogLevel)
24114: [Unity] Google.IOSResolver:RunPodCommand(String, String)
24115: [Unity] Google.IOSResolver:OnPostProcessInstallPods(BuildTarget, String)
24116: [Unity] UnityEditor.BuildPipeline:BuildPlayerInternalNoCheck(String[], String, String, BuildTarget, BuildOptions, Boolean)
24117: [Unity] UnityEditor.CloudBuild.Builder:Build()
24118: [Unity] Error running cocoapods. Please ensure you have at least version  1.0.0.  You can install cocoapods with the Ruby gem package manager:
24119: [Unity]  > sudo gem install -n /usr/local/bin cocoapods
24120: [Unity]  > pod setup
24121: [Unity] 'pod --version' returned status: 1
24122: [Unity] output: 
24123: [Unity] UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
24124: [Unity] UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
24125: [Unity] UnityEngine.Logger:Log(LogType, Object)
24126: [Unity] UnityEngine.Debug:LogError(Object)
24127: [Unity] Google.IOSResolver:Log(String, Boolean, LogLevel)
24128: [Unity] Google.IOSResolver:OnPostProcessInstallPods(BuildTarget, String)
24129: [Unity] UnityEditor.BuildPipeline:BuildPlayerInternalNoCheck(String[], String, String, BuildTarget, BuildOptions, Boolean)
24130: [Unity] UnityEditor.CloudBuild.Builder:Build()

Has anyone found a workaround to allow us to make cloud builds again?

Currently, the JarResolver library does not support Unity Cloud builds, but we are working to fill that gap in functionality. Look for an update on this soon.

Hello!

So a fellow programmer @tammukul here found a way to build. We have NOT tested AdMob with this yet, but it allows us to test everything else we need for now.

  1. AdMobDependencies.cs contains the code that attempts to use cocoapods. We added a preprocessor directive to disable this for cloud builds.
#elif UNITY_IOS && !CLOUDBUILD
        Type iosResolver = Google.VersionHandler.FindClass(
            "Google.IOSResolver", "Google.IOSResolver");
        if (iosResolver == null) {
            return;
        }
        Google.VersionHandler.InvokeStaticMethod(
            iosResolver, "AddPod",
            new object[] { "Google-Mobile-Ads-SDK" },
            namedArgs: new Dictionary<string, object>() {
                { "version", "7.13+" }
            });
#endif
  1. Edit the XCode project to enable CLANG_ENABLE_MODULES. We use UnityEditor.iOS.Xcode.PBXProject for this and run this command after the XCode project has been created.
    proj.SetBuildProperty (target, "CLANG_ENABLE_MODULES" , "YES" );

So while this allowed us to use Unity Cloud Build again, I still need to see if it disables AdMob.

@GarthSmith if you're taking this approach to disable dependency resolution, you'll want to ensure you're including the Google Mobile Ads iOS framework at the Assets/Plugins/iOS/ directory of your Unity project.

We solved this issue by using "UNITY_CLOUD_BUILD" preprocessor directive instead of "CLOUDBUILD" and adding the plugin to Assets/Plugins/iOS/ directory.

Is cloud build still not working on the latest version of this plugin?

I ran into the same issues with GoogleMobileAds 3.5.0 and Unity Cloud Build for iOS. The recent answers here were correct, but I thought it might be helpful to summarize everything:

  1. Add GoogleMobileAds.framework to Assets/Plugins/iOS/...

  2. Add a [PostProcessBuild] function to modify the generated Xcode project:

    using System.Collections;
    using System.Collections.Generic;
    using System.IO;
    using UnityEngine;
    using UnityEditor;
    using UnityEditor.Callbacks;
    using UnityEditor.iOS.Xcode;

    public static class XcodeProjectModifer {

        [PostProcessBuild]
        public static void OnPostProcessBuild(BuildTarget buildTarget, string path) {
            if (buildTarget == BuildTarget.iOS) {
                string projPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj";

                PBXProject proj = new PBXProject();
                proj.ReadFromString(File.ReadAllText(projPath));
                string target = proj.TargetGuidByName("Unity-iPhone");

                // GoogleMobileAds (aka AdMob):
                proj.AddBuildProperty(target, "CLANG_ENABLE_MODULES", "YES");
                proj.AddBuildProperty(target, "OTHER_LDFLAGS", "$(inherited)");

                File.WriteAllText(projPath, proj.WriteToString());
            }
        }
    }
  1. Add the UNITY_CLOUD_BUILD define to AdMobDependencies.cs like so:
    #elif UNITY_IOS && !UNITY_CLOUD_BUILD
            Type iosResolver = Google.VersionHandler.FindClass(
                "Google.IOSResolver", "Google.IOSResolver");
            if (iosResolver == null) {
                return;
            }
            Google.VersionHandler.InvokeStaticMethod(
                iosResolver, "AddPod",
                new object[] { "Google-Mobile-Ads-SDK" },
                namedArgs: new Dictionary<string, object>() {
                    { "version", "7.13+" }
                });
    #endif

Also generally disable usage of Cocoapods in your Unity project if you want to use UCB:

https://forum.unity3d.com/threads/build-failed-cocoapods.421286/

Currently working on getting Unity Cloud Build working out of the box (without the need for these workarounds). Look for an update on this soon.

Not only Admob or Firebase, but some other systems also require CocoaPods. My game is using DeltaDNA Analytics which also requires CocoaPods.

@rampara any updates on this ? We are looking at moving to Jenkins again as this seems to be still be broken, full on undocumented and unmanaged work arounds and hacks.

A legitimate fix that manages Cocoapods and then runs through the workspace would be the best direction.

Any idea of timeframe @rampara, happy to update what's necessary to get this working.

Regards,

@akurani unfortunately when running the [PostProcessBuild] in unity 5.6.1f1 our UCB crashes when trying to execute XcodeProjectModifer . There is explanation in the console log. Since our release builds are done in an older version of Unity, it would be good to know which version of unity is being run on UCB with these work arounds...

@petersuwara I had UCB set to use "Latest Unity 5.x" which was probably 5.6.1f1 when I last ran this in May, but I could be wrong.

Looking at my instructional comment, the only step I didn't explicitly spell out: Unity Editor >> Assets >> Play Services resolver >> ios Resolver >> Settings >> Cocoapods Integration >> none - Do not integrate Cocoapods. I remember I needed to make sure all trace of Cocoapods was completely removed from the generated Xcode project for it to work in UCB.

I paused that project. I'm coming back to it now, but I'm upgrading to GoogleMobileAds 3.7.0 and Unity 2017.1 first. So anything I do next will reflect that.

@petersuwara @akurani Unity Cloud build should now work out of the box with the latest version of this plugin (with no changes required via PostProcesBuild scripts). Is that not the case for you?

Closing as Unity Cloud builds should now work.

@rampara thanks, we got it working without any issues.

Was this page helpful?
0 / 5 - 0 ratings