在使用 Carthage 的 AppCenter 中构建应用程序

Build app in AppCenter that uses Carthage

我继承了一个使用 Carthage 构建的项目。使用 Xcode 12,我遇到了这个错误:

fatal error: /Applications/Xcode_12.3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo: /Users/runner/Library/Caches/org.carthage.CarthageKit/DerivedData/12.3_12C33/AEXML/4.6.0/Build/Intermediates.noindex/ArchiveIntermediates/AEXML iOS/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/AEXML.framework/AEXML and /Users/runner/Library/Caches/org.carthage.CarthageKit/DerivedData/12.3_12C33/AEXML/4.6.0/Build/Products/Release-iphonesimulator/AEXML.framework/AEXML have the same architectures (arm64) and can't be in the same fat output file

用通用架构构建通用框架是不可能的。 “AEXML”的设备和模拟器切片均构建为:arm64 使用 --use-xcframeworks 重建以创建 xcframework 包。

Quick Google search brought me to this 适用于我的本地计算机。

第一次使用 AppCenter,我创建了一个 Pre-Build script,内容如下:

#!/usr/bin/env bash

# Pre-build
# See: https://docs.microsoft.com/en-us/appcenter/build/custom/scripts/#pre-build
echo "Pre-build has started."
sh ./carthage.sh update --use-submodules
echo "Pre-build has ended."

我猜迦太基应该用来建造这个?我在 AppCenter 中收到错误:

*** Building scheme "AEXML iOS" in AEXML.xcodeproj A shell task (/usr/bin/xcrun lipo -create /Users/runner/Library/Caches/org.carthage.CarthageKit/DerivedData/12.3_12C33/AEXML/4.6.0/Build/Intermediates.noindex/ArchiveIntermediates/AEXML\ iOS/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/AEXML.framework/AEXML /Users/runner/Library/Caches/org.carthage.CarthageKit/DerivedData/12.3_12C33/AEXML/4.6.0/Build/Products/Release-iphonesimulator/AEXML.framework/AEXML -output /Users/runner/work/1/s/Carthage/Build/iOS/AEXML.framework/AEXML) failed with exit code 1: fatal error: /Applications/Xcode_12.3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo: /Users/runner/Library/Caches/org.carthage.CarthageKit/DerivedData/12.3_12C33/AEXML/4.6.0/Build/Intermediates.noindex/ArchiveIntermediates/AEXML iOS/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/AEXML.framework/AEXML and /Users/runner/Library/Caches/org.carthage.CarthageKit/DerivedData/12.3_12C33/AEXML/4.6.0/Build/Products/Release-iphonesimulator/AEXML.framework/AEXML have the same architectures (arm64) and can't be in the same fat output file

用通用架构构建通用框架是不可能的。 “AEXML”的设备和模拟器切片均构建为:arm64 使用 --use-xcframeworks 重建以创建 xcframework 包。

如何在 AppCenter 中构建?

--use-xcframeworks

此选项仅适用于 Carthage 0.37.0。 appcenter的carthage版本是0.36.0。他们需要更新 appcenter 项目中使用的 carthage。

您能否查看日志并查看此脚本是否正在 运行?还是 appcenter 正在 运行ning carthage 二进制文件?

编辑

好消息是appcenter识别出carthage 0.37.0!我在我的项目目录中添加了一个appcenter-post-clone.sh

#!/usr/bin/env bash

set -e
set -x

carthage update --cache-builds --use-xcframeworks --platform ios
carthage version
echo "" > Cartfile
echo "" > Cartfile.resolved

appcenter 识别出使用了 --use-xcframeworks,因此需要 0.37.0。

注意:我正在清空 Cartfile*,这样 appcenter 就不会 运行 它的本地 carthage 命令(它会在注意到 Cartfile 和 Cartfile.resolved 时执行)。

编辑 2

我现在正在考虑在 appcenter 中使用 carthage_cache 之类的东西,因为迦太基结帐和构建最终会花费很多时间。

试试这个(你可能需要先升级你的迦太基)

carthage update --no-use-binaries --use-xcframeworks --platform iOS