Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Xcode 12 Carthage Build Workaround
#!/bin/bash -e
echo "🤡 Applying carthage 12.2 workaround 🤡"
xcconfig=$(mktemp /tmp/static.xcconfig.XXXXXX)
# 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 = arm64 arm64e armv7 armv7s armv6 armv8' > $xcconfig
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 = $(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 "$@"
@skymobilebuilds

This comment has been minimized.

Copy link
Owner Author

@skymobilebuilds skymobilebuilds commented Sep 17, 2020

For Xcode 12.0.0 (12A7209) use (RECOMMENDED, AS 12.0.1 HAS VARIOUS CARTHAGE BUILD ISSUES EVEN WITH THE WORKAROUND):

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

Verification checksums:

sha256: 5bcd369bdd041f1dcb74357d314fd204c9455752c5246d33b6e4e67989b93d6c
MD5: 4ac819672bdf1bddf39f2524adb1e4da
sha1: 460a90be5aacc91a4be7b411620d57f5fe7c29ed

For Xcode 12.0.1 (12A7300) use:

Installation:

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

Verification checksums:

sha256: 42ae315f58092d67fa826807b0c0eda4ffd20a5cf1001016fac809d15cc366e3
md5: caf21ac2f90837f030cc6663465acf4e
sha1: 2d02fe9567ab0f4ee51a43901c9c1340d5ad68fa

For Xcode 12.2.0 use:

Installation:

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

Usage:

./wcarthage bootstrap --platform iOS --cache-builds
./wcarthage update --platform iOS --cache-builds
./wcarthage build --archive
@prgorasiya

This comment has been minimized.

Copy link

@prgorasiya prgorasiya commented Sep 18, 2020

thanks a lot, this saved me!

@pigfly

This comment has been minimized.

Copy link

@pigfly pigfly commented Sep 18, 2020

Hi @skymobilebuilds,

Thanks for the gist, got a quick question, does this applies to all Xcode 12 beta version or just GM ?

EXCLUDED_ARCHS__EFFECTIVE_PLATFORM might be different between different Xcode 12 versions.

@skymobilebuilds

This comment has been minimized.

Copy link
Owner Author

@skymobilebuilds skymobilebuilds commented Sep 18, 2020

@pigfly this applies only to Xcode 12.0 (12A7209) as there's no reason, at least for me, to keep using older beta versions

@chriswunsch00

This comment has been minimized.

Copy link

@chriswunsch00 chriswunsch00 commented Sep 18, 2020

Nice work - just running this now !

@JT501

This comment has been minimized.

Copy link

@JT501 JT501 commented Sep 18, 2020

work like a charm!

@serhatleventyavas

This comment has been minimized.

Copy link

@serhatleventyavas serhatleventyavas commented Sep 18, 2020

Nice work, thanks a lot, this saved me!

@bguidolim

This comment has been minimized.

Copy link

@bguidolim bguidolim commented Sep 18, 2020

Well done. Thanks :)

@drosenstark

This comment has been minimized.

Copy link

@drosenstark drosenstark commented Sep 18, 2020

This is running perfectly, depositing and picking up the file in tmp. Perhaps the error I'm hitting is different? I can build the Xcode project for device. However, building for simulator I get this message:

Module 'DeviceKit' was created for incompatible target arm64-apple-ios9.0: .../Carthage/build/iOS/DeviceKit.framework/Modules/DeviceKit.swiftmodule/arm64.swiftmodule

Is this the problem that we're solving here, builds for device but not for simulator?

Thanks for doing this.

(Upgrading to Carthage 0.36 didn't help. Also this is Version 12.2 beta (12B5018i))

@chriswunsch00

This comment has been minimized.

Copy link

@chriswunsch00 chriswunsch00 commented Sep 18, 2020

Carthage release notes says that .36 doesn’t fix this.

I have that issue too re sim but it makes sense since this is omitting those arch’s. You should still be able top build for device/archive?

@drosenstark

This comment has been minimized.

Copy link

@drosenstark drosenstark commented Sep 18, 2020

Carthage release notes says that .36 doesn’t fix this.

I have that issue too re sim but it makes sense since this is omitting those arch’s. You should still be able top build for device/archive?

Correct, I can build for device and probably archive, but not simulator.

Weirdly, this is the same error that happens whether I use Carthage normally or use this script.

@unixb0y

This comment has been minimized.

Copy link

@unixb0y unixb0y commented Sep 19, 2020

Thanks so much, works like a charm!

@terryworona

This comment has been minimized.

Copy link

@terryworona terryworona commented Sep 19, 2020

Thanks for the script. I too can't build to simulator. Device is fine.

Xcode (12 GM) console:

The file couldn’t be saved.
Command PhaseScriptExecution failed with a nonzero exit code
@SergejLogis

This comment has been minimized.

Copy link

@SergejLogis SergejLogis commented Sep 21, 2020

Immense thanks! Saved a day (week, actually) for me! 🙇

@manifity

This comment has been minimized.

Copy link

@manifity manifity commented Sep 21, 2020

This isn't helped me with Original error: Unable to launch WebDriverAgent because of xcodebuild failure: Command 'carthage bootstrap --platform iOS\\,tvOS' exited with code 1". What I need to do to fix this?

Thank in adnvance!

@zylz10

This comment has been minimized.

Copy link

@zylz10 zylz10 commented Sep 21, 2020

thanks a lot, this saved me!

@KeiroMidori

This comment has been minimized.

Copy link

@KeiroMidori KeiroMidori commented Sep 21, 2020

Saved me thank you for this !

@s4cha

This comment has been minimized.

Copy link

@s4cha s4cha commented Sep 22, 2020

@skymobilebuilds, you sir, deserve a medal of honor 🎖️

@odanu

This comment has been minimized.

Copy link

@odanu odanu commented Sep 24, 2020

This is running perfectly, depositing and picking up the file in tmp. Perhaps the error I'm hitting is different? I can build the Xcode project for device. However, building for simulator I get this message:

Module 'DeviceKit' was created for incompatible target arm64-apple-ios9.0: .../Carthage/build/iOS/DeviceKit.framework/Modules/DeviceKit.swiftmodule/arm64.swiftmodule

Is this the problem that we're solving here, builds for device but not for simulator?

Thanks for doing this.

(Upgrading to Carthage 0.36 didn't help. Also this is Version 12.2 beta (12B5018i))

I am experiencing the same issue but with Swinject framework.
Module 'Swinject' was created for incompatible target arm64-apple-ios9.0

@drosenstark did you find a solution?

@notohiro

This comment has been minimized.

Copy link

@notohiro notohiro commented Sep 24, 2020

This is super nice!

@odanu

This comment has been minimized.

Copy link

@odanu odanu commented Sep 25, 2020

For anyone getting project compile errors like Module 'xxx' was created for incompatible target arm64-apple-ios9.0 after applying this patch, there is one thing to be done, to fix it.
Exclude arm64 from every scheme for iOS Simluator SDK, inside your target.
Screenshot 2020-09-25 at 15 13 21

@yuhanle

This comment has been minimized.

Copy link

@yuhanle yuhanle commented Sep 27, 2020

There is a problem in this case.

readium/r2-testapp-swift#351

@PacoPacoPakitor

This comment has been minimized.

Copy link

@PacoPacoPakitor PacoPacoPakitor commented Oct 2, 2020

`*** Building scheme "OmiseSDK" in OmiseSDK.xcodeproj
Build Failed
Task failed with exit code 1:
/usr/bin/xcrun lipo -create /Users/paco/Library/Caches/org.carthage.CarthageKit/DerivedData/12.0.1_12A7300/omise-ios/v3.5.0/Build/Intermediates.noindex/ArchiveIntermediates/OmiseSDK/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/OmiseSDK.framework/OmiseSDK /Users/paco/Library/Caches/org.carthage.CarthageKit/DerivedData/12.0.1_12A7300/omise-ios/v3.5.0/Build/Products/Release-iphonesimulator/OmiseSDK.framework/OmiseSDK -output /Users/paco/wf-ios/Carthage/Build/iOS/OmiseSDK.framework/OmiseSDK

This usually indicates that project itself failed to compile. Please check the xcodebuild log for more details: /var/folders/ys/5mpd508n7cn480b721dsq99m0000gn/T/carthage-xcodebuild.XnxTXQ.log`

@rob5408

This comment has been minimized.

Copy link

@rob5408 rob5408 commented Oct 6, 2020

`*** Building scheme "OmiseSDK" in OmiseSDK.xcodeproj
Build Failed
Task failed with exit code 1:
/usr/bin/xcrun lipo -create /Users/paco/Library/Caches/org.carthage.CarthageKit/DerivedData/12.0.1_12A7300/omise-ios/v3.5.0/Build/Intermediates.noindex/ArchiveIntermediates/OmiseSDK/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/OmiseSDK.framework/OmiseSDK /Users/paco/Library/Caches/org.carthage.CarthageKit/DerivedData/12.0.1_12A7300/omise-ios/v3.5.0/Build/Products/Release-iphonesimulator/OmiseSDK.framework/OmiseSDK -output /Users/paco/wf-ios/Carthage/Build/iOS/OmiseSDK.framework/OmiseSDK

This usually indicates that project itself failed to compile. Please check the xcodebuild log for more details: /var/folders/ys/5mpd508n7cn480b721dsq99m0000gn/T/carthage-xcodebuild.XnxTXQ.log`

Same for me, but the log says BUILD SUCCESSFUL.

@funzin

This comment has been minimized.

Copy link

@funzin funzin commented Oct 8, 2020

#!/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 $@

If you've already switched to Xcode12, this will still work without adding a version.

@bguidolim

This comment has been minimized.

Copy link

@bguidolim bguidolim commented Oct 14, 2020

@funzin well done

@bscothern

This comment has been minimized.

Copy link

@bscothern bscothern commented Nov 17, 2020

Thank you @funzin for the great update to the script.

@nickynova

This comment has been minimized.

Copy link

@nickynova nickynova commented Feb 19, 2021

where to include this script when trying to solve this issue?
#!/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 $@

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment