Skip to content

Instantly share code, notes, and snippets.

@skymobilebuilds
Last active May 17, 2022 12:36
Show Gist options
  • Star 56 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save skymobilebuilds/61f4a95bd62a3db36b52719aeab7e0d5 to your computer and use it in GitHub Desktop.
Save skymobilebuilds/61f4a95bd62a3db36b52719aeab7e0d5 to your computer and use it in GitHub Desktop.
Xcode 13 and 12 Carthage Build Workaround
#!/bin/bash -e
echo "🤡 Applying carthage 12 and 13 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__EFFECTIVE_PLATFORM_SUFFIX_simulator__NATIVE_ARCH_64_BIT_x86_64__XCODE_1300 = arm64 arm64e armv7 armv7s armv6 armv8' >> $xcconfig
echo "EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_simulator__NATIVE_ARCH_64_BIT_x86_64__XCODE_1300__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 "$@"
@odanu
Copy link

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
Copy link

This is super nice!

@odanu
Copy link

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
Copy link

yuhanle commented Sep 27, 2020

@PacoPacoPakitor
Copy link

`*** 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
Copy link

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
Copy link

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
Copy link

@funzin well done

@bscothern
Copy link

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

@nickynova
Copy link

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