Xcode云测试无法存档项目



存档时Xcode云测试出错。

问题都与CocoaPods依赖性有关:

unable to open file (in target "Alamofire" in project "Pods")

missing module map file: '/Volumes/workspace/repository/Pods/Target Support Files/Alamofire/Alamofire.modulemap

看起来pods没有安装在存档中。

它在本地运行良好。

最佳,

Xcode Cloud临时构建环境不包括像CocoaPods这样的第三方工具。但您可以使用克隆后脚本将它们包括在内。以下是使用CocoaPods的步骤。

  1. 在项目的根目录中创建一个目录ci_scripts

  2. 添加一个文件ci_post_clone.sh并将其保存在ci_scripts目录中。

  3. 打开Terminal,使脚本可执行,并在ci_scripts目录中运行chmod +x ci_post_clone.sh

  4. 在任何文本编辑器中编辑ci_post_clone.sh,并复制以下内容。

    # !/bin/sh
    # Install CocoaPods using Homebrew.
    brew install cocoapods
    # Install dependencies you manage with CocoaPods.
    pod install
    
  5. 提交并推送ci_post_clone.sh

CocoaPods、Carthage或SPM的答案如下:https://developer.apple.com/documentation/xcode/making-dependencies-available-to-xcode-cloud#Use-a-Custom-Build-Script-to-Install-AThird-Party-Dependency-or-Tool

文档建议的设置方式很糟糕——它没有版本控制,而且通过brew安装需要很多时间。最好的方法是有一个Gemfile,它在repo的根上声明依赖项,即:

source 'https://rubygems.org'
gem 'cocoapods'
gem 'fastlane'

然后bundle install锁定Gemfile.lock上的工具版本(您应该在您的repo中对这两个文件进行版本设置(。

ci_scripts/ci_post_clone.sh文件上:

#!/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

此外,考虑提交Pods文件夹,以避免运行cocoapods。或者至少只gitignore大型二进制文件(如Twilio、WebRTC等(。这也保护您免受删除的转发或离线服务提供商的影响

最新更新