Reputation: 684
I have errors with Xcode Cloud testing while archiving. Issues are all related to CocoaPods dependencies:
unable to open file (in target "Alamofire" in project "Pods")
missing module map file: '/Volumes/workspace/repository/Pods/Target Support Files/Alamofire/Alamofire.modulemap
Looks like Pods are not being installed on archiving. It works well locally.
Best,
Upvotes: 3
Views: 2699
Reputation: 684
The answer is here for CocoaPods, Carthage or SPM :
Use a custom build script to install a third-party dependency or tool
Upvotes: 2
Reputation: 5131
The documentation suggested way of setting this up is terrible - it has no versioning, and it takes a lot of time to install through brew.
The best way is having a Gemfile
that declares the dependencies at the root of your repo, ie:
source 'https://rubygems.org'
gem 'cocoapods'
gem 'fastlane'
Then bundle install
it to lock the versions of the tools on a Gemfile.lock
(you should version both files in your repo).
On your ci_scripts/ci_post_clone.sh
file:
#!/bin/sh
#1 - You can't install gems to the system gem path without sudo, so create a local one
echo ">>> SETUP LOCAL GEM PATH"
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"
#2 - Install the actual bundler version you bundled locally with, so you don't have any surprises
echo ">>> INSTALL REQUIRED BUNDLER VERSION"
gem install bundler -v "$(grep -A 1 "BUNDLED WITH" ../Gemfile.lock | tail -n 1)" --install-dir $GEM_HOME
#3 - Let bundler download the locked version of cocoapods, fastlane, and whatever other tools you need
echo ">>> INSTALL DEPENDENCIES"
bundle install
#4 - Finally you can run the bundled pod binary to install your dependencies
echo ">>> INSTALL PODS"
bundle exec pod install
Also, consider commiting your Pods
folder to avoid the need to run cocoapods at all. Or at least gitignore only large binaries (i.e Twilio, WebRTC, etc). This also protects you from deleted repos or offline services providers
Upvotes: 0
Reputation: 19156
Xcode Cloud temporary build environment doesn't include third party tools like CocoaPods. But you can include them using post clone script. Here are the steps if you are using CocoaPods.
Create a directory ci_scripts
at the root of your project.
Add a file ci_post_clone.sh
and save it in the ci_scripts directory.
Open Terminal
and make your script executable be running chmod +x ci_post_clone.sh
in ci_scripts
directory.
Edit the ci_post_clone.sh
in any text editor and copy the following.
# !/bin/sh
# Install CocoaPods using Homebrew.
brew install cocoapods
# Install dependencies you manage with CocoaPods.
pod install
Commit and push ci_post_clone.sh
.
Upvotes: 7