@@ -8,14 +8,72 @@ set -euo pipefail
88xcconfig=$( mktemp /tmp/static.xcconfig.XXXXXX)
99trap ' rm -f "$xcconfig"' INT TERM HUP EXIT
1010
11- # For Xcode 12 make sure EXCLUDED_ARCHS is set to arm architectures otherwise
11+ # For Xcode 12+ make sure EXCLUDED_ARCHS is set to arm architectures otherwise
1212# the build will fail on lipo due to duplicate architectures.
13+ # Enhanced for Xcode 16 compatibility
1314
1415CURRENT_XCODE_VERSION=$( xcodebuild -version | grep " Build version" | cut -d' ' -f3)
1516echo " 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
1617
1718echo ' 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
1819echo ' EXCLUDED_ARCHS = $(inherited) $(EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_$(EFFECTIVE_PLATFORM_SUFFIX)__NATIVE_ARCH_64_BIT_$(NATIVE_ARCH_64_BIT)__XCODE_$(XCODE_VERSION_MAJOR))' >> $xcconfig
1920
21+ # Add Xcode 16 specific build settings to avoid common build issues
22+ echo ' ENABLE_USER_SCRIPT_SANDBOXING = NO' >> $xcconfig
23+ echo ' DEAD_CODE_STRIPPING = NO' >> $xcconfig
24+ echo ' COMPILER_INDEX_STORE_ENABLE = NO' >> $xcconfig
25+ echo ' ENABLE_PREVIEWS = NO' >> $xcconfig
26+
2027export XCODE_XCCONFIG_FILE=" $xcconfig "
21- carthage " $@ "
28+
29+ # Function to attempt building with fallback strategies
30+ attempt_carthage_build () {
31+ local attempt=$1
32+ local extra_flags=" "
33+
34+ case $attempt in
35+ 1)
36+ echo " 📦 Attempt 1: Standard Carthage build"
37+ ;;
38+ 2)
39+ echo " 📦 Attempt 2: Building with --no-use-binaries flag"
40+ extra_flags=" --no-use-binaries"
41+ ;;
42+ 3)
43+ echo " 📦 Attempt 3: Building with platform-specific flags"
44+ extra_flags=" --no-use-binaries --platform iOS,macOS,tvOS"
45+ ;;
46+ esac
47+
48+ if carthage " $@ " $extra_flags ; then
49+ echo " ✅ Carthage build succeeded on attempt $attempt "
50+ return 0
51+ else
52+ echo " ❌ Carthage build failed on attempt $attempt "
53+ return 1
54+ fi
55+ }
56+
57+ # Retry logic with different strategies
58+ max_attempts=3
59+ for attempt in $( seq 1 $max_attempts ) ; do
60+ if attempt_carthage_build $attempt " $@ " ; then
61+ exit 0
62+ fi
63+
64+ if [ $attempt -lt $max_attempts ]; then
65+ echo " ⏳ Waiting 30 seconds before next attempt..."
66+ sleep 30
67+
68+ # Clean up any partial builds
69+ echo " 🧹 Cleaning up partial builds..."
70+ rm -rf Carthage/Build
71+ fi
72+ done
73+
74+ echo " 💥 All Carthage build attempts failed. Check the build log for details."
75+ echo " 🔍 Common solutions:"
76+ echo " 1. Try running: rm -rf ~/Library/Caches/org.carthage.CarthageKit"
77+ echo " 2. Try running: rm -rf Carthage && carthage update"
78+ echo " 3. Check if dependencies are compatible with Xcode 16"
79+ exit 1
0 commit comments