8

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?

sudeepdino008
  • 3,194
  • 5
  • 39
  • 73
Sylar
  • 11,422
  • 25
  • 93
  • 166

2 Answers2

7
--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.

sudeepdino008
  • 3,194
  • 5
  • 39
  • 73
  • Hi thanks. AppCenter is using its own script to build and I cannot seem to change that. It seems I need to tell AppCenter to build with carthage.sh but not sure how. Was that useful? – Sylar Feb 15 '21 at 11:00
  • Yeah. So I believe appcenter is then running you pre-build script as well as carthage command since it finds a Cartfile in the directory. – sudeepdino008 Feb 15 '21 at 11:05
  • Appcenter has this optimization to *not* run `pod install` when it sees a Pods folder in the project directory. I wonder if some similar optimization is there for Carthage - i.e. If Carthage/Build folder is there, it won't run the carthage command. This way you might be able to just run your carthage.sh and not appcenter's carthage. – sudeepdino008 Feb 15 '21 at 11:07
  • Though the better solution would definitely be for appcenter to provide more flexibility with how users want to use cocoapods or carthage etc. – sudeepdino008 Feb 15 '21 at 11:07
  • My project is weird. The .gitignore file has Carthage/Build in it but it's still in the git repo. Ok... I'll remove that from git and report my finds later. Thanks for some pointers. – Sylar Feb 15 '21 at 11:09
  • Morning. This looks promising. I'll have a go in a few hours and I'll let you know but this looks really promising. Thanks – Sylar Feb 16 '21 at 04:36
  • That post clone script did it. Thank you! – Sylar Feb 17 '21 at 01:47
  • you can "accept" the answer so that users know that this solved your problem. :) @Sylar – sudeepdino008 Oct 27 '21 at 17:25
5

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

carthage update --no-use-binaries --use-xcframeworks --platform iOS 
Harry Zhang
  • 799
  • 9
  • 6