| 1 | #!/usr/bin/env sh |
| 2 | set -e |
| 3 | |
| 4 | BOLD_GREEN="\033[1;35m" |
| 5 | RESET="\033[0m" |
| 6 | |
| 7 | status() { |
| 8 | label="$1" |
| 9 | shift |
| 10 | printf "%b%12s%b %s\n" "$BOLD_GREEN" "$label" "$RESET" "$*" |
| 11 | } |
| 12 | |
| 13 | EXAMPLE="${1:-un_async}" |
| 14 | APP=target/debug/examples/bundle/osx/notify-rust.app |
| 15 | |
| 16 | status "Bundling" "$EXAMPLE (example)" |
| 17 | cargo bundle --example "$EXAMPLE" --features preview-macos-un |
| 18 | |
| 19 | status "Signing" "$APP (ad-hoc)" |
| 20 | codesign --force --deep --sign - "$APP" |
| 21 | |
| 22 | status "Opening" "$APP" |
| 23 | pkill -x "$EXAMPLE" 2>/dev/null || true |
| 24 | open "$APP" |
| 25 | |
| 26 | # Give the app a moment to launch, then grab its PID. |
| 27 | sleep 0.5 |
| 28 | APP_PID=$(pgrep -x "$EXAMPLE" | head -1) |
| 29 | |
| 30 | status "Streaming" "logs for process: $EXAMPLE (PID $APP_PID — stops when app exits)" |
| 31 | # First replay any logs already emitted since the app launched, then stream live. |
| 32 | # Both commands include debug level messages. |
| 33 | PREDICATE="process == \"$EXAMPLE\" AND subsystem == \"notify-rust\"" |
| 34 | # Uncomment the line below to also include Apple's internal UserNotifications/XPC logs: |
| 35 | # PREDICATE="process == \"$EXAMPLE\"" |
| 36 | log show \ |
| 37 | --predicate "$PREDICATE" \ |
| 38 | --style compact \ |
| 39 | --debug \ |
| 40 | --info \ |
| 41 | --last 2s |
| 42 | log stream \ |
| 43 | --predicate "$PREDICATE" \ |
| 44 | --style compact \ |
| 45 | --level debug & |
| 46 | LOG_PID=$! |
| 47 | |
| 48 | # Wait for the app to exit, then stop the log stream. |
| 49 | while kill -0 "$APP_PID" 2>/dev/null; do |
| 50 | sleep 0.5 |
| 51 | done |
| 52 | status "Done" "$EXAMPLE exited — stopping log stream" |
| 53 | kill "$LOG_PID" 2>/dev/null || true |