Calling `pod install` from a System.Diagnostics.Process

When we build our Unity project for iOS, it generates an Xcode project which uses Cocoapods. I’m trying to make a build post-process script (C#, running in the Unity Editor) that edits the Podfile and then runs pod install in the build directory.

I’ve tried several different approaches to run pod install which all fail in one of two ways:

private static void ExecuteProcess(string directory, string argument) {
    try {
        System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo() {
            FileName = "/bin/bash",
            UseShellExecute = false,
            RedirectStandardError = true,
            RedirectStandardInput = true,
            RedirectStandardOutput = true,
            CreateNoWindow = true,
            WorkingDirectory = directory,
            Arguments = " -c "" + argument + " ""
        };

        System.Diagnostics.Process myProcess = new System.Diagnostics.Process {
            StartInfo = startInfo
        };
        myProcess.Start();
        while (!myProcess.StandardOutput.EndOfStream) {
        var line = myProcess.StandardOutput.ReadLine();
            UnityEngine.Debug.Log(line);
        }

    } catch (System.Exception e) {
        UnityEngine.Debug.Log(e);
    }
}

private static void TryInstallPods() {
    const string BUILDS_PATH = "./Builds";
    string shellScriptPath = Path.Join(BUILDS_PATH, "podinstall.sh");

    // Outputs nothing
    File.WriteAllText(shellScriptPath, "pod install --verbose");
    ExecuteProcess(BUILDS_PATH, "sh podinstall.sh");

    // Outputs "CDN: trunk Relative path: CocoaPods-version.yml exists! Returning local because checking is only performed in repo update"
    File.WriteAllText(shellScriptPath, "/usr/local/bin/pod install --verbose");
    ExecuteProcess(BUILDS_PATH, "sh podinstall.sh");

    // Outputs nothing
    ExecuteProcess(BUILDS_PATH, "pod install --verbose");
    
    // Outputs "CDN: trunk Relative path: CocoaPods-version.yml exists! Returning local because checking is only performed in repo update"
    ExecuteProcess(BUILDS_PATH, "/usr/local/bin/pod install --verbose");

    // For reference, this works as expected for the build directory:
    ExecuteProcess(BUILDS_PATH, "ls");
    // This also works as expected:
    ExecuteProcess(BUILDS_PATH, "/usr/local/bin/pod --help");
    // This produces no output:
    ExecuteProcess(BUILDS_PATH, "pod --help");
}

Note that this shell script is generated by the code:

podinstall.sh

/usr/local/bin/pod install --verbose

  1. From my C# code, pod install --verbose produces no output, whether it’s called directly or from inside a shell script.
  2. From my C# code, "/usr/local/bin/pod install --verbose" produces the output “CDN: trunk Relative path: CocoaPods-version.yml exists! Returning local because checking is only performed in repo update”, whether it’s called directly or from inside a shell script. Nothing else happens and the pod configuration isn’t updated.

I get the same results if I try the approach described here: https://forum.unity.com/threads/adjusting-pods-pods-xcproject-after-pod-install.1406500/

However, any variation works if I open a terminal window in the build folder and type the command there:

% pod install --verbose

% /usr/local/bin/pod install --verbose

% sh podinstall.sh

Why do these commands work if I type them into the terminal window, but not when I try to run them from a process in C#/Unity?

Note: I have reformatted the code for this question; this question might contain typos that are not present in the original code.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật