Skip to content

Commit 3268a17

Browse files
committed
fix: bundle Sparkle.framework in Swift app to prevent launch crash
The Swift binary links @rpath/Sparkle.framework at runtime. Without the framework in Contents/Frameworks/, macOS shows "cannot be opened because of a problem" (dyld: Library missing). build-swift-app.sh now: 1. Searches .build/artifacts/ for Sparkle.framework (from swift build) 2. Falls back to downloading Sparkle release tarball if not found (swiftc) 3. Copies to Contents/Frameworks/ in the .app bundle Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 0a7fa79 commit 3268a17

1 file changed

Lines changed: 35 additions & 2 deletions

File tree

scripts/build-swift-app.sh

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,44 @@ fi
158158
# PkgInfo
159159
echo "APPLMCPP" > "$APP_BUNDLE/Contents/PkgInfo"
160160

161-
# Copy Sparkle framework if built
162-
SPARKLE_FRAMEWORK=".build/artifacts/sparkle/Sparkle.xcframework/macos-arm64_x86_64/Sparkle.framework"
161+
# Copy Sparkle.framework — required at runtime (@rpath linked)
162+
# Search multiple locations where swift build may place it
163+
SPARKLE_FRAMEWORK=""
164+
for candidate in \
165+
".build/artifacts/sparkle/Sparkle.xcframework/macos-arm64_x86_64/Sparkle.framework" \
166+
".build/artifacts/sparkle/Sparkle/Sparkle.framework" \
167+
"$(find .build -name "Sparkle.framework" -type d 2>/dev/null | head -1)"; do
168+
if [ -d "$candidate" ]; then
169+
SPARKLE_FRAMEWORK="$candidate"
170+
break
171+
fi
172+
done
173+
163174
if [ -d "$SPARKLE_FRAMEWORK" ]; then
164175
mkdir -p "$APP_BUNDLE/Contents/Frameworks"
165176
cp -R "$SPARKLE_FRAMEWORK" "$APP_BUNDLE/Contents/Frameworks/"
177+
echo "✅ Sparkle.framework bundled from: $SPARKLE_FRAMEWORK"
178+
else
179+
echo "⚠️ Sparkle.framework NOT found — app will crash at launch!"
180+
echo " This is expected with swiftc fallback (no SPM dependency resolution)"
181+
echo " CI builds with 'swift build' should have it available"
182+
# For swiftc builds, we need to either:
183+
# 1. Download Sparkle manually, or
184+
# 2. Remove the Sparkle dependency from the binary
185+
# Let's download it as a fallback
186+
SPARKLE_VERSION="2.9.1"
187+
SPARKLE_URL="https://github.com/sparkle-project/Sparkle/releases/download/${SPARKLE_VERSION}/Sparkle-${SPARKLE_VERSION}.tar.xz"
188+
SPARKLE_TMP="/tmp/sparkle-download"
189+
mkdir -p "$SPARKLE_TMP"
190+
if curl -sL "$SPARKLE_URL" -o "$SPARKLE_TMP/Sparkle.tar.xz" 2>/dev/null; then
191+
tar xf "$SPARKLE_TMP/Sparkle.tar.xz" -C "$SPARKLE_TMP" 2>/dev/null
192+
if [ -d "$SPARKLE_TMP/Sparkle.framework" ]; then
193+
mkdir -p "$APP_BUNDLE/Contents/Frameworks"
194+
cp -R "$SPARKLE_TMP/Sparkle.framework" "$APP_BUNDLE/Contents/Frameworks/"
195+
echo "✅ Sparkle.framework downloaded and bundled (v${SPARKLE_VERSION})"
196+
fi
197+
fi
198+
rm -rf "$SPARKLE_TMP"
166199
fi
167200

168201
cd - > /dev/null

0 commit comments

Comments
 (0)