Build app in AppCenter that uses Carthage

4.3k views Asked by At

I've inherited a project that builds with Carthage. Using Xcode 12, I was faced with this error:

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

Building universal frameworks with common architectures is not possible. The device and simulator slices for "AEXML" both build for: arm64 Rebuild with --use-xcframeworks to create an xcframework bundle instead.

Quick Google search brought me to this which works for my local machine.

Using AppCenter for the first time, I created a Pre-Build script with the following:

#!/usr/bin/env bash

# Pre-build
# See: https://learn.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."

I assume Carthage should be used to build this? I get the error in 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

Building universal frameworks with common architectures is not possible. The device and simulator slices for "AEXML" both build for: arm64 Rebuild with --use-xcframeworks to create an xcframework bundle instead.

How to build in AppCenter?

2

There are 2 answers

8
sudeepdino008 On BEST ANSWER
--use-xcframeworks

This option is only available from Carthage 0.37.0. The appcenter's carthage version is 0.36.0. They need to update the carthage used in appcenter projects.

Can you look at the logs and see if this script is being run? Or is it that appcenter is running the carthage binary?

EDIT

The good news is that appcenter identifies carthage 0.37.0! I added a appcenter-post-clone.sh in my project directory:

#!/usr/bin/env bash

set -e
set -x

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

appcenter recognises that --use-xcframeworks is used and therefore 0.37.0 is required.

NOTE: I'm emptying the Cartfile* so that appcenter doesn't run its native carthage command (which it does on noticing Cartfile and Cartfile.resolved).

EDIT 2

I'm now considering using something like carthage_cache in appcenter as the carthage checkout and build ends up taking a lot of time.

0
Harry Zhang On

Try this one (you may need to upgrade your Carthage first)

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