skip to Main Content

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,

3

Answers



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

    1. Create a directory ci_scripts at the root of your project.

    2. Add a file ci_post_clone.sh and save it in the ci_scripts directory.

    3. Open Terminal and make your script executable be running chmod +x ci_post_clone.sh in ci_scripts directory.

    4. 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
      
    5. Commit and push ci_post_clone.sh.

    Login or Signup to reply.
  2. 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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search