mirror of
https://github.com/AgentSeal/codeburn.git
synced 2026-07-26 09:24:59 +00:00
fix(mac): address review notes on PR #577 — correct SDK/deployment-target wording, universal build-local.sh, CI minos guard
- README.md / build-local.sh: the -10825 fix is the Package.swift deployment target, not the SDK used to build (ld64's $ld$previous drops libswift_errno.dylib based on minos, so it already applies to the CI-distributed release too). build-local.sh exists only for building on a Sonoma machine with just the Command Line Tools. - build-local.sh: build arm64 and x86_64 separately and lipo them into a universal binary (`--arch arm64 --arch x86_64` together needs xcbuild, which CLT doesn't ship); assert the active SDK is actually 14.x instead of silently trusting `xcrun`; use `pkill -x` instead of `-f` to avoid matching unrelated processes; broaden the @MainActor patch regex to slurp mode so it also covers multi-line struct headers and `extension X: View`. - package-app.sh: fail the build if the packaged binary's minos isn't 14.0 for every arch slice, or if it links libswift_errno.dylib, so a future deployment-target regression is caught in CI instead of a user's crash report.
This commit is contained in:
parent
a91c1c9f2a
commit
c8bddb52c2
3 changed files with 70 additions and 21 deletions
|
|
@ -35,8 +35,15 @@ swift build -c release
|
|||
`swift build` above assumes the macOS 15 SDK, whose SwiftUI marks the `View`
|
||||
protocol `@MainActor`. The Sonoma SDK (shipped with Command Line Tools) lacks
|
||||
that annotation, so a plain build fails with ~80 `main actor-isolated ... from a
|
||||
nonisolated context` errors, and a stock CI build links the macOS-15-only
|
||||
`libswift_errno.dylib` (the root of the `-10825` launch failure on Sonoma).
|
||||
nonisolated context` errors.
|
||||
|
||||
(The `-10825` launch failure itself is fixed by `Package.swift`'s `.macOS(.v14)`
|
||||
deployment target: ld64 drops the macOS-15-only `libswift_errno.dylib`
|
||||
dependency for any build with that target, regardless of which SDK built it —
|
||||
including the CI-distributed release. This local-build path exists only for
|
||||
the narrower case of building on a Sonoma machine with nothing but the
|
||||
Command Line Tools, where the SDK's un-annotated `View` protocol needs the
|
||||
`@MainActor` patch below.)
|
||||
|
||||
Use the helper, which builds against the local macOS 14 SDK with a standalone
|
||||
[swift.org](https://www.swift.org/install/macos/) Swift 6.x toolchain and
|
||||
|
|
|
|||
|
|
@ -4,17 +4,19 @@
|
|||
# ============================================================================
|
||||
# Why this exists
|
||||
# ---------------
|
||||
# The released .app is built in CI with the macOS 15 SDK + Swift 6. That binary
|
||||
# hard-links /usr/lib/swift/libswift_errno.dylib, which only ships in macOS 15,
|
||||
# so `codeburn menubar` fails on Sonoma with:
|
||||
# kLSIncompatibleSystemVersionErr (-10825)
|
||||
# Package.swift's `.macOS(.v14)` deployment target already fixes the -10825
|
||||
# launch failure for every build, including the CI-distributed release: ld64
|
||||
# drops the macOS-15-only libswift_errno.dylib dependency based on the
|
||||
# deployment target, not the SDK used to build. This script is not about that.
|
||||
#
|
||||
# This script builds an arm64 bundle locally against the machine's macOS 14 SDK
|
||||
# (no libswift_errno dependency, minos = 14.0) using a swift.org Swift 6.2
|
||||
# toolchain. Because the macOS 14 SDK's SwiftUI does NOT carry the @MainActor
|
||||
# annotations that the macOS 15 SDK added to the `View` protocol, the sources
|
||||
# are copied to a scratch dir and every `View`/`App` struct is given an explicit
|
||||
# `@MainActor` there — the repo sources stay untouched.
|
||||
# It exists for the narrower case of building on a Sonoma machine that only
|
||||
# has the Command Line Tools (macOS 14 SDK). That SDK's SwiftUI does NOT carry
|
||||
# the @MainActor annotations the macOS 15 SDK added to the `View` protocol, so
|
||||
# a plain `swift build` there fails with ~80 `main actor-isolated ... from a
|
||||
# nonisolated context` errors. This script copies the sources to a scratch
|
||||
# dir, gives every `View`/`App` conformance an explicit `@MainActor` there
|
||||
# (repo sources stay untouched), and builds a universal bundle with a
|
||||
# swift.org Swift 6.2 toolchain against the local macOS 14 SDK.
|
||||
#
|
||||
# Prerequisites
|
||||
# - Command Line Tools (provides the macOS 14 SDK + sips/iconutil/codesign)
|
||||
|
|
@ -53,8 +55,18 @@ if [[ -z "${TC}" ]]; then
|
|||
fi
|
||||
SWIFT="${TC}/usr/bin/swift"
|
||||
export SDKROOT="$(xcrun --sdk macosx --show-sdk-path)"
|
||||
SDK_VERSION="$(xcrun --sdk macosx --show-sdk-version)"
|
||||
case "${SDK_VERSION}" in
|
||||
14.*) ;;
|
||||
*)
|
||||
echo "✗ Active SDK is macOS ${SDK_VERSION}, not 14.x — xcode-select is likely" >&2
|
||||
echo " pointed at a newer Xcode instead of the Command Line Tools. Run:" >&2
|
||||
echo " sudo xcode-select -s /Library/Developer/CommandLineTools" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
echo "▸ Toolchain : $("${SWIFT}" --version | head -1)"
|
||||
echo "▸ SDK : ${SDKROOT} ($(xcrun --sdk macosx --show-sdk-version))"
|
||||
echo "▸ SDK : ${SDKROOT} (${SDK_VERSION})"
|
||||
|
||||
# --- copy sources and add explicit @MainActor to SwiftUI views --------------
|
||||
echo "▸ Staging sources in ${SCRATCH}..."
|
||||
|
|
@ -62,19 +74,34 @@ echo "▸ Staging sources in ${SCRATCH}..."
|
|||
# (product only) never compiles it, so it needs no @MainActor patching.
|
||||
cp -R "${MAC_DIR}/Sources" "${MAC_DIR}/Tests" "${MAC_DIR}/Package.swift" "${SCRATCH}/"
|
||||
find "${SCRATCH}/Sources" -name "*.swift" -print0 | while IFS= read -r -d '' f; do
|
||||
perl -i -pe 's/^((?:private |public |fileprivate )?struct \b.*: .*\bView\b.*\{)/\@MainActor\n$1/; s/^(struct \w+ *: *App\b.*\{)/\@MainActor\n$1/' "$f"
|
||||
perl -0777 -i -pe 's/\@MainActor\n\@MainActor\n/\@MainActor\n/g' "$f"
|
||||
# Slurp mode ([^{]* spans newlines) so this also catches multi-line generic
|
||||
# struct headers and `extension X: View` conformances, not just the
|
||||
# single-line `struct X: View {` shape the current sources happen to use.
|
||||
perl -0777 -i -pe '
|
||||
s/^((?:private |public |fileprivate |internal )?(?:struct|extension)\s+\w+(?:<[^{]*?>)?\s*:[^{]*\bView\b[^{]*\{)/\@MainActor\n$1/gm;
|
||||
s/^(struct\s+\w+\s*:[^{]*\bApp\b[^{]*\{)/\@MainActor\n$1/gm;
|
||||
s/\@MainActor\n\@MainActor\n/\@MainActor\n/g;
|
||||
' "$f"
|
||||
done
|
||||
|
||||
# --- build arm64 release (single-arch avoids xcbuild, absent from CLT) -------
|
||||
echo "▸ Building arm64 release..."
|
||||
( cd "${SCRATCH}" && "${SWIFT}" build -c release )
|
||||
BIN="$(cd "${SCRATCH}" && "${SWIFT}" build -c release --show-bin-path)/${EXE}"
|
||||
[[ -x "${BIN}" ]] || { echo "✗ build produced no binary" >&2; exit 1; }
|
||||
# --- build each arch separately, then lipo into one universal binary --------
|
||||
# `swift build --arch arm64 --arch x86_64` together shells out to xcbuild,
|
||||
# which the Command Line Tools doesn't ship — each arch alone stays on the
|
||||
# plain SwiftPM build path, so build twice and merge with lipo instead.
|
||||
BINS=()
|
||||
for arch in arm64 x86_64; do
|
||||
echo "▸ Building ${arch} release..."
|
||||
( cd "${SCRATCH}" && "${SWIFT}" build -c release --arch "${arch}" )
|
||||
bin="$(cd "${SCRATCH}" && "${SWIFT}" build -c release --arch "${arch}" --show-bin-path)/${EXE}"
|
||||
[[ -x "${bin}" ]] || { echo "✗ ${arch} build produced no binary" >&2; exit 1; }
|
||||
BINS+=("${bin}")
|
||||
done
|
||||
BIN="${SCRATCH}/${EXE}-universal"
|
||||
lipo -create -output "${BIN}" "${BINS[@]}"
|
||||
|
||||
# --- assemble the .app bundle ------------------------------------------------
|
||||
echo "▸ Assembling ${BUNDLE}..."
|
||||
pkill -f "${EXE}" 2>/dev/null || true; sleep 1
|
||||
pkill -x "${EXE}" 2>/dev/null || true; sleep 1
|
||||
rm -rf "${BUNDLE}"
|
||||
mkdir -p "${BUNDLE}/Contents/MacOS" "${BUNDLE}/Contents/Resources"
|
||||
cp "${BIN}" "${BUNDLE}/Contents/MacOS/${EXE}"
|
||||
|
|
@ -118,5 +145,6 @@ codesign --verify --deep --strict "${BUNDLE}"
|
|||
|
||||
echo ""
|
||||
echo "✓ Installed ${BUNDLE}"
|
||||
lipo -info "${BUNDLE}/Contents/MacOS/${EXE}" | sed 's/^/ /'
|
||||
vtool -show-build "${BUNDLE}/Contents/MacOS/${EXE}" 2>/dev/null | grep -iE "minos|sdk" | sed 's/^/ /'
|
||||
echo " Launch with: codeburn menubar (or: open '${BUNDLE}')"
|
||||
|
|
|
|||
|
|
@ -120,6 +120,20 @@ else
|
|||
fi
|
||||
codesign --verify --deep --strict "${BUNDLE}"
|
||||
|
||||
echo "▸ Verifying deployment target and libswift_errno absence..."
|
||||
BUILT_EXE="${BUNDLE}/Contents/MacOS/${EXECUTABLE_NAME}"
|
||||
BAD_MINOS=$(vtool -show-build "${BUILT_EXE}" 2>/dev/null | awk '/minos/{print $2}' | grep -v '^14\.0$' || true)
|
||||
if [[ -n "${BAD_MINOS}" ]]; then
|
||||
echo "✗ Expected minos 14.0 for every arch slice, found: ${BAD_MINOS}" >&2
|
||||
echo " Did Package.swift's platforms: [.macOS(...)] regress past .v14?" >&2
|
||||
exit 1
|
||||
fi
|
||||
if otool -L "${BUILT_EXE}" | grep -q libswift_errno; then
|
||||
echo "✗ ${BUILT_EXE} links libswift_errno.dylib (macOS 15+ only) — would fail on Sonoma with -10825." >&2
|
||||
exit 1
|
||||
fi
|
||||
echo " minos 14.0 confirmed, no libswift_errno dependency."
|
||||
|
||||
ZIP_NAME="CodeBurnMenubar-${ASSET_VERSION}.zip"
|
||||
ZIP_PATH="${DIST_DIR}/${ZIP_NAME}"
|
||||
echo "▸ Packaging ${ZIP_NAME}..."
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue