Home > Software design >  Xcode Cloud project with CocoaPods shell script builds locally but fails on cloud
Xcode Cloud project with CocoaPods shell script builds locally but fails on cloud

Time:02-26

I am currently testing Xcode Cloud as a member of Apple's private beta program and encountered an issue when trying to Archive / Build (any action) on the cloud for my project.

The project is a fairly basic SwiftUI app with CocoaPods dependencies. I have followed the steps to integrate CocoaPods into my project Xcode Cloud error log

This is very strange because the same project builds and archives successfully on my local machine. I have used the same macOS and Xcode versions in the Workflow editor as my local version of Xcode.

How can I resolve this error?

CodePudding user response:

Custom shell scripts restrictions

TL;DR

Apple has locked down the security of their hosted infrastructure by only enabling shell scripts to run as part of ci_post_clone.sh, ci_pre_xcodebuild.sh or ci_post_xcodebuild.sh in the ci_scripts folder. Your Pods project has a custom shell script outside of this folder that is not triggered by one of these CI scripts, so does not have running permissions.

The solution for this specific issue are:

  1. (technically) Refactor your build script phase to inline the shell script file inside the run script.
  2. (recommended, but not always possible) Use the Swift Package version of the CocoaPod if available.
  3. (workaround) Downgrade the CocoaPod to a version without an external shell script.

Reference

From Xcode Pods Shell Script refactor 1

Solution 2 (recommended, but not always possible)

Add the Swift Package version of the CocoaPod as a dependency following Apple's documentation.

Solution 3 (workaround)

Downgrade your CocoaPod to a version without external shell scripts.

Notes

As you can tell from the amount of effort required to workaround custom shell script build phases with Xcode Cloud, I suggest raising an issue on the specific CocoaPod repository to migrate away from custom shell script files. These kinds of steps make using Xcode Cloud very painful.

As Xcode Cloud adoption grows it is entirely possible that individual CocoaPods no longer reference custom shell script files. I don't see Apple opening up their infrastructure to enable arbitrary shell script execution because this is a security risk, and to be honest, should have been prevented on other CI providers too.

I can also see how hassles like these to include legacy CocoaPods dependencies could accelerate more projects to migrate to SPM. SPM is already popular, and will likely become more popular as Apple ensures first-class integration.

  • Related