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

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?

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 15 (6 by maintainers)

Most upvoted comments

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.

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

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/

@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.