1+ #! /usr/bin/env bash
2+
3+ # debug-carthage-build.sh
4+ # Script to debug and troubleshoot Carthage build issues
5+
6+ set -euo pipefail
7+
8+ echo " 🔍 Carthage Build Troubleshooter"
9+ echo " =================================="
10+
11+ # Function to print section headers
12+ print_section () {
13+ echo " "
14+ echo " 📋 $1 "
15+ echo " $( printf ' %.0s-' {1..50}) "
16+ }
17+
18+ # Check Xcode version
19+ print_section " Xcode Information"
20+ xcodebuild -version
21+ xcrun --show-sdk-path
22+ echo " Xcode path: $( xcode-select -p) "
23+
24+ # Check Carthage version
25+ print_section " Carthage Information"
26+ carthage version
27+
28+ # Check current dependencies
29+ print_section " Current Dependencies"
30+ echo " Cartfile contents:"
31+ cat Cartfile || echo " No Cartfile found"
32+ echo " "
33+ echo " Cartfile.resolved contents:"
34+ cat Cartfile.resolved || echo " No Cartfile.resolved found"
35+
36+ # Check for tweetnacl-swiftwrap specific issues
37+ print_section " TweetNacl-SwiftWrap Analysis"
38+ if [ -d " Carthage/Checkouts/tweetnacl-swiftwrap" ]; then
39+ echo " ✅ tweetnacl-swiftwrap checkout exists"
40+ echo " Directory contents:"
41+ ls -la Carthage/Checkouts/tweetnacl-swiftwrap/
42+
43+ echo " "
44+ echo " Xcode project info:"
45+ if [ -f " Carthage/Checkouts/tweetnacl-swiftwrap/TweetNacl.xcodeproj/project.pbxproj" ]; then
46+ echo " ✅ Xcode project exists"
47+ # Check deployment targets
48+ grep -A 1 -B 1 " MACOSX_DEPLOYMENT_TARGET\|IPHONEOS_DEPLOYMENT_TARGET\|TVOS_DEPLOYMENT_TARGET" \
49+ Carthage/Checkouts/tweetnacl-swiftwrap/TweetNacl.xcodeproj/project.pbxproj | head -20
50+ else
51+ echo " ❌ Xcode project not found"
52+ fi
53+ else
54+ echo " ❌ tweetnacl-swiftwrap checkout not found"
55+ fi
56+
57+ # Test specific build command
58+ print_section " Testing Build Command"
59+ echo " Attempting to build tweetnacl-swiftwrap directly..."
60+ if [ -d " Carthage/Checkouts/tweetnacl-swiftwrap" ]; then
61+ cd Carthage/Checkouts/tweetnacl-swiftwrap
62+ echo " Testing xcodebuild command..."
63+ set +e # Don't exit on error for this test
64+
65+ xcodebuild -project TweetNacl.xcodeproj \
66+ -scheme TweetNacl-macOS \
67+ -configuration Release \
68+ -sdk macosx \
69+ ONLY_ACTIVE_ARCH=NO \
70+ CODE_SIGNING_REQUIRED=NO \
71+ CODE_SIGN_IDENTITY= \
72+ SUPPORTS_MACCATALYST=NO \
73+ clean build 2>&1 | head -50
74+
75+ build_result=$?
76+ cd - > /dev/null
77+
78+ if [ $build_result -eq 0 ]; then
79+ echo " ✅ Direct build succeeded"
80+ else
81+ echo " ❌ Direct build failed with exit code $build_result "
82+ fi
83+ set -e
84+ else
85+ echo " ⚠️ Cannot test build - checkout directory not found"
86+ fi
87+
88+ # Suggestions
89+ print_section " Troubleshooting Suggestions"
90+ echo " 1. 🧹 Clear all caches:"
91+ echo " rm -rf ~/Library/Caches/org.carthage.CarthageKit"
92+ echo " rm -rf Carthage"
93+ echo " "
94+ echo " 2. 🔄 Update dependencies:"
95+ echo " carthage update --platform iOS,macOS,tvOS"
96+ echo " "
97+ echo " 3. 🚫 Try without binaries:"
98+ echo " carthage update --no-use-binaries"
99+ echo " "
100+ echo " 4. 📱 Try platform-specific build:"
101+ echo " carthage update --platform iOS"
102+ echo " "
103+ echo " 5. 🔀 Consider switching to Swift Package Manager:"
104+ echo " Your project already supports SPM - check Package.swift"
105+ echo " "
106+ echo " 6. 🔧 Manual workaround if needed:"
107+ echo " - Fork tweetnacl-swiftwrap"
108+ echo " - Update for Xcode 16 compatibility"
109+ echo " - Point Cartfile to your fork"
110+
111+ echo " "
112+ echo " 🎯 Quick Fix Commands:"
113+ echo " ======================"
114+ echo " # Clean and retry:"
115+ echo " rm -rf ~/Library/Caches/org.carthage.CarthageKit && rm -rf Carthage && carthage bootstrap --use-xcframeworks"
116+ echo " "
117+ echo " # Force rebuild without binaries:"
118+ echo " carthage update --no-use-binaries --use-xcframeworks"
0 commit comments