Skip to content

Instantly share code, notes, and snippets.

@1oo7
Created December 14, 2020 19:59
Show Gist options
  • Save 1oo7/174e53b74e5abcdfbae748c0f4fac669 to your computer and use it in GitHub Desktop.
Save 1oo7/174e53b74e5abcdfbae748c0f4fac669 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# Carthage Workaround Script
# How to use:
# 1. Rename carthage itself to "_carthage" to use this.
# 2. Save this script to /usr/local/bin/carthage and use as normal.
# 3. ....
# 4. PROFIT!!
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.
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__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_1200 = $(EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_simulator__NATIVE_ARCH_64_BIT_x86_64__XCODE_1200__BUILD_$(XCODE_PRODUCT_BUILD_VERSION))' >> $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
# Additional settings needed for my project (not needed for carthage)
echo 'GCC_TREAT_WARNINGS_AS_ERRORS=NO' >> $xcconfig
echo 'GCC_C_LANGUAGE_STANDARD=compiler-default' >> $xcconfig
echo 'SWIFT_TREAT_WARNINGS_AS_ERRORS=NO' >> $xcconfig
# Final step from official carthage workaround script:
export XCODE_XCCONFIG_FILE="$xcconfig"
_carthage "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment