visit
One of the key features of Xcode Cloud is the ability to resolve dependencies automatically. If you’re using the Swift Package Manager, Xcode Cloud will look at the Package.resolved
file to resolve dependencies. However, if you're using other dependency managers like Cocoapods or Carthage, you'll need to install them first. This is where Bundler comes in handy.
To use Bundler with Xcode Cloud, you can create a directory named ci_scripts
under the project root directory and create a custom script there to execute during workflow execution. Xcode Cloud executes custom scripts at specific points during the workflow. For example, the ci_post_clone.sh
script is executed after Xcode Cloud clones a Git repository.
Here is an example ci_post_clone.sh
script for resolving dependencies:
#!/bin/sh
cd ..
echo ">>> SETUP ENVIRONMENT"
echo 'export GEM_HOME=$HOME/gems' >>~/.bash_profile
echo 'export PATH=$HOME/gems/bin:$PATH' >>~/.bash_profile
export GEM_HOME=$HOME/gems
export PATH="$GEM_HOME/bin:$PATH"
echo ">>> INSTALL BUNDLER"
gem install bundler --install-dir $GEM_HOME
echo ">>> INSTALL DEPENDENCIES"
bundle install
echo ">>> INSTALL PODS"
bundle exec pod install
In this script, we first set up the environment by adding GEM_HOME
and PATH
to ~/.bash_profile
. Then we install Bundler and run bundle install
to install all required gems specified in the Gemfile
. Finally, we run bundle exec pod install
to install any dependencies managed by Cocoapods.
It’s worth noting that at the time of writing this article, there appears to be an issue with Cocoapods’ compatibility with Xcode 14.3. To resolve this, you may need to use a solution from this thread: //github.com/CocoaPods/CocoaPods/pull/11828. This involves adding a custom row to the Gemfile
to add all changes from the master branch before it was released:
gem 'cocoapods', :git => '//github.com/CocoaPods/CocoaPods.git', :branch => 'master'