Xcode Cloud测试无法对项目进行存档

3

我在使用 Xcode 云测试进行归档时遇到了错误。

所有问题都与 CocoaPods 依赖项有关:

无法打开文件(在项目“Pods”中的目标“Alamofire”中)

缺少模块映射文件:'/Volumes/workspace/repository/Pods/Target Support Files/Alamofire/Alamofire.modulemap

看起来 Pods 没有在归档时被安装。

在本地运行良好。

祝好,

3个回答

7

Xcode Cloud临时构建环境不包含像CocoaPods这样的第三方工具。但是您可以使用后克隆脚本来包含它们。如果您正在使用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.


他们的云服务器上没有安装brew... - Yaroslav Dukal
1
Homebrew可用,我尝试过了,它可以正常工作。 - Bilal
@YaroslavDukal 是的,它在几周前停止工作了。之前它是可以工作的,而且在苹果文档中也提到了brew命令,链接在这里https://developer.apple.com/documentation/xcode/making-dependencies-available-to-xcode-cloud#Use-a-Custom-Build-Script-to-Install-a-Third-Party-Dependency-or-Tool 。由于它仍处于beta版本,所以可能会有一些变化或错误。 - Bilal
它能工作...但我很失望,由于所有这些后安装的东西,构建需要很长时间...我的MacBook Pro编译速度更快,而且不必在每次构建时安装第三方依赖项...不建议使用它。 - Yaroslav Dukal


0

文档中建议的设置方式很糟糕 - 它没有版本控制,并且通过brew安装需要很长时间。 最好的方法是在您的存储库根目录下拥有一个Gemfile,声明依赖项:

source 'https://rubygems.org'

gem 'cocoapods'
gem 'fastlane'

然后使用 bundle install 命令锁定工具的版本到 Gemfile.lock 文件中(你应该将这两个文件都纳入版本控制)。

在你的 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的需要。或者至少只忽略大型二进制文件(例如Twilio,WebRTC等)。这也可以保护您免受已删除的存储库或离线服务提供商的影响。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接