diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 89d71f2..7689eb1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -41,7 +41,7 @@ jobs: - name: Package app bundle if: startsWith(github.ref, 'refs/tags/v') - run: APP_BINARY=.build/universal/PDFReader APP_VERSION="${GITHUB_REF_NAME}" APP_BUILD="${GITHUB_RUN_NUMBER}" ./scripts/make-app.sh release + run: ./scripts/make-app.sh release release APP_BINARY=.build/universal/PDFReader APP_VERSION="${GITHUB_REF_NAME}" APP_BUILD="${GITHUB_RUN_NUMBER}" - name: Build DMG if: startsWith(github.ref, 'refs/tags/v') diff --git a/scripts/make-app.sh b/scripts/make-app.sh index 2a46ec0..4afd6c5 100755 --- a/scripts/make-app.sh +++ b/scripts/make-app.sh @@ -35,8 +35,16 @@ else fi rm -rf "$APP_DIR" -mkdir -p "$APP_DIR/Contents/MacOS" "$APP_DIR/Contents/Resources" +mkdir -p "$APP_DIR/Contents/MacOS" "$APP_DIR/Contents/Frameworks" "$APP_DIR/Contents/Resources" cp "$BIN" "$APP_DIR/Contents/MacOS/PDFReader" +# The binary's Sparkle load command uses @rpath, but SwiftPM only emits +# toolchain rpaths (/usr/lib/swift, …). Without an app-bundle rpath, dyld +# can never resolve @rpath/Sparkle.framework from Contents/Frameworks and +# the app aborts at launch (DYLD "Library missing"). Add it if absent. +EXEC="$APP_DIR/Contents/MacOS/PDFReader" +if ! otool -l "$EXEC" | grep -q 'path @executable_path/../Frameworks'; then + xcrun install_name_tool -add_rpath '@executable_path/../Frameworks' "$EXEC" +fi # Copy Sparkle framework for update checking cp -R ".build/$CONFIG/Sparkle.framework" "$APP_DIR/Contents/Frameworks/" # App icon (generated by scripts/generate-icon.swift).