【iOS】Xcode 12 Carthage Update Ta

2020-11-13  本文已影响0人  海外党一枚

问题

升级Xcode12后,Carthage 配置出现问题,无法使用,出现了失败:

Carthage Update Task failed with exit code 1

原因

Well, shortly, Carthage builds fat frameworks, which means that the framework contains binaries for all supported architectures. Until Apple Sillicon was introduced it all worked just fine, but now there is a conflict as there are duplicate architectures (arm64 for devices and arm64 for simulator). This means that Carthage cannot link architecture specific frameworks to a single fat framework.

解决方案

创建脚本脚本carthage.sh,放到/usr/local/bin/目录下,然后执行如下命令

chmod +x /usr/local/bin/carthage.sh

脚本内容如下:

#carthage.sh

#Usage example: ./carthage.sh build --platform iOS

set -euo pipefail

xcconfig=$(mktemp /tmp/static.xcconfig.XXXXXX)

trap 'rm -f "$xcconfig"' INT TERM HUP EXIT

#For Xcode 12 make sure EXCLUDED_ARCHS is set to arm architectures otherwise

#the build will fail on lipo due to duplicate architectures.

CURRENT_XCODE_VERSION = $(xcodebuild -version | grep "Build version" | cut -d ' ' -f3)

echo "EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_simulator__NATIVE_ARCH_64_BIT_x86_64__XCODE_1200__BUILD_$CURRENT_XCODE_VERSION= arm64 arm64e armv7 armv7s armv6 armv8" >> $xcconfig

echo 'EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_simulator__NATIVE_ARCH_64_BIT_x86_64__XCODE_1200 = $(EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_simulator__NATIVE_ARCH_64_BIT_x86_64__XCODE_1200__BUILD_$(XCODE_PRODUCT_BUILD_VERSION))' >> $xcconfig

echo 'EXCLUDED_ARCHS = $(inherited) $(EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_$(EFFECTIVE_PLATFORM_SUFFIX)__NATIVE_ARCH_64_BIT_$(NATIVE_ARCH_64_BIT)__XCODE_$(XCODE_VERSION_MAJOR))' >> $xcconfig

export XCODE_XCCONFIG_FILE = "$xcconfig"

carthage "$@"

使用方法

carthage.sh update --platform iOS

上一篇下一篇

猜你喜欢

热点阅读