Carthage构建失败 Xcode 12 12A7209构建

11

Carthage的文件内容:

github "SwiftyJSON/SwiftyJSON"

错误:

Build Failed
Task failed with exit code 1:
/usr/bin/xcrun lipo -create /Users/samrezikram/Library/Caches/org.carthage.CarthageKit/DerivedData/12.0_12A7209/SwiftyJSON/5.0.0/Build/Intermediates.noindex/ArchiveIntermediates/SwiftyJSON\ tvOS/IntermediateBuildFilesPath/UninstalledProducts/appletvos/SwiftyJSON.framework/SwiftyJSON /Users/samrezikram/Library/Caches/org.carthage.CarthageKit/DerivedData/12.0_12A7209/SwiftyJSON/5.0.0/Build/Products/Release-appletvsimulator/SwiftyJSON.framework/SwiftyJSON -output /Users/samrezikram/Downloads/CarthageApp/Carthage/Build/tvOS/SwiftyJSON.framework/SwiftyJSON

This usually indicates that project itself failed to compile. Please check the xcodebuild log for more details: /var/folders/px/jx4gljpj47j06qr7blw6b4w80000gn/T/carthage-xcodebuild.1NVy7o.log
3个回答

20

这是一个Carthage和Xcode 12的问题。不幸的是,目前Carthage团队还没有更新来解决这个问题。然而,有一个shell脚本可以运行以解除阻止。它对我起作用了。您可以在Carthage github帐户上关注此线程。 https://github.com/Carthage/Carthage/issues/3019#issuecomment-665136323

  1. 创建一个名为carthage-build.sh的shell脚本并将其放置在您的Xcode项目中
#!/usr/bin/env bash

# carthage.sh
# Usage example: ./carthage-build.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.
echo 'EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_simulator__NATIVE_ARCH_64_BIT_x86_64__XCODE_1200 = arm64 arm64e armv7 armv7s armv6 armv8' >> $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框架
  • $ ./carthage-build.sh build --platform iOS
    

    你的框架应该能够更新和编译。

    FYI - 我没有写这个脚本,功劳归属于https://github.com/rastersize

    请在此处跟进此问题的更新。 https://github.com/Carthage/Carthage/issues/3019


    1
    以上代码已经不适用于Xcode 12.0.1。您可以从https://github.com/Carthage/Carthage/issues/3019#issuecomment-699143260获取更新后的脚本。 - Casey
    @Casey,你说得对,我会更新我的答案并给作者以功劳。 - MiMo
    1
    谢谢你的回答!!!它为我节省了很多时间。你唯一忘记的事情是,在创建脚本后,你应该使用这个命令使脚本可执行:"chmod +x carthage-build.sh"。 - Shahen Kosyan

    6
    为了避免更新Carthage时出现/usr/bin/xcrun lipo -create问题,我们需要修改工作区配置。
    • 打开终端并导航到工作区目录。

    Xcode 12.0

    • 运行curl https://gist.githubusercontent.com/skymobilebuilds/61f4a95bd62a3db36b52719aeab7e0d5/raw/4ba422e5f3a5e7e37cdcb1e232058c5431fc59fc/carthage-xc12.sh -o wcarthage && chmod +x wcarthage

    Xcode 12.0.1

    • 运行curl https://gist.githubusercontent.com/skymobilebuilds/61f4a95bd62a3db36b52719aeab7e0d5/raw/f638b57097897b38fc0b1e62a527a814952968d7/carthage-xc12.sh -o wcarthage && chmod +x wcarthage

    Xcode 12.2

    在wcarthage文件中使用此脚本。

    #!/bin/sh -e
    echo "Carthage wrapper"
    echo "Applying Xcode 12 workaround..."
    xcconfig="/tmp/xc12-carthage.xcconfig"
    
    # Xcode 12.x
    echo 'EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_simulator__NATIVE_ARCH_64_BIT_x86_64__XCODE_1200 = arm64 arm64e armv7 armv7s armv6 armv8' > $xcconfig
    
    # General stuff
    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
    echo 'ONLY_ACTIVE_ARCH=NO' >> $xcconfig
    echo 'VALID_ARCHS = $(inherited) x86_64' >> $xcconfig
    export XCODE_XCCONFIG_FILE="$xcconfig"
    echo "Workaround applied. xcconfig here: $XCODE_XCCONFIG_FILE"
    
    carthage $@
    
    • 下载完成 wcarthage 后,根据需求运行以下任一命令。

      ./wcarthage update --platform iOS --cache-builds 或者 ./wcarthage bootstrap --platform iOS --cache-builds

    我在 skymobilebuilds 找到了这个解决方案。


    是的,请在上面的答案中找到Xcode 12.2的脚本更改。 - Rajasekhar Pasupuleti

    0

    我也遇到了同样的问题 - 这通常表示项目本身无法编译。

    这是与Xcode 12有关的问题。在我的情况下,这个方法有效(来自skymobilebuilds的修复)

    在终端中使用以下命令:

    curl https://gist.githubusercontent.com/skymobilebuilds/61f4a95bd62a3db36b52719aeab7e0d5/raw/61affe5b13efaeb83ba3aaf5ef2cb97bab893485/carthage-xc12.sh -o wcarthage && chmod +x wcarthage    
    

    然后用法是,

    ./wcarthage update --platform iOS 
    

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