存档时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的步骤。
-
在项目的根目录中创建一个目录
ci_scripts
。 -
添加一个文件
ci_post_clone.sh
并将其保存在ci_scripts目录中。 -
打开
Terminal
,使脚本可执行,并在ci_scripts
目录中运行chmod +x ci_post_clone.sh
。 -
在任何文本编辑器中编辑
ci_post_clone.sh
,并复制以下内容。# !/bin/sh # Install CocoaPods using Homebrew. brew install cocoapods # Install dependencies you manage with CocoaPods. pod install
-
提交并推送
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等(。这也保护您免受删除的转发或离线服务提供商的影响