From da7296af99d0b68b4eeaa953fecb2a7da1566501 Mon Sep 17 00:00:00 2001 From: spark Date: Sun, 18 Oct 2026 23:45:01 +0000 Subject: [PATCH] Desktop 0.3.20 keeps macOS folder permissions between launches and updates. Unsigned, each build looked like a new app to macOS, so the Desktop prompt came back again and again. The installer is now signed with one identity (a Developer ID when given, else a local one made once in the login keychain), and the app says why it needs each folder. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_017sovZz1NXBwx4VySojoyA1 --- apps/desktop/package.json | 2 +- apps/desktop/src-tauri/Cargo.toml | 2 +- apps/desktop/src-tauri/Info.plist | 17 +++++++++++++ apps/desktop/src-tauri/tauri.conf.json | 2 +- infra/desktop/build-macos.sh | 35 ++++++++++++++++++++++++++ 5 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 apps/desktop/src-tauri/Info.plist diff --git a/apps/desktop/package.json b/apps/desktop/package.json index b612830..153f381 100644 --- a/apps/desktop/package.json +++ b/apps/desktop/package.json @@ -1,6 +1,6 @@ { "name": "@photoreport/desktop", - "version": "0.3.19", + "version": "0.3.20", "private": true, "type": "module", "scripts": { diff --git a/apps/desktop/src-tauri/Cargo.toml b/apps/desktop/src-tauri/Cargo.toml index aa96c0d..f754ef5 100644 --- a/apps/desktop/src-tauri/Cargo.toml +++ b/apps/desktop/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "photoreport-desktop" -version = "0.3.19" +version = "0.3.20" edition = "2024" publish = false description = "PhotoReport desktop: the web app in a native shell, with keychain sign-in and (later) local FTP and the native engine." diff --git a/apps/desktop/src-tauri/Info.plist b/apps/desktop/src-tauri/Info.plist new file mode 100644 index 0000000..6e686da --- /dev/null +++ b/apps/desktop/src-tauri/Info.plist @@ -0,0 +1,17 @@ + + + + + + NSDesktopFolderUsageDescription + O PhotoReport lê a pasta de entrada (FTP) e guarda os originais de cada evento na Secretária. + NSDocumentsFolderUsageDescription + O PhotoReport lê e guarda fotografias nas pastas que escolheres em Documentos. + NSDownloadsFolderUsageDescription + O PhotoReport lê fotografias que estejam nas Transferências, quando escolhes essa pasta. + NSRemovableVolumesUsageDescription + O PhotoReport copia as fotografias dos cartões de memória. + NSNetworkVolumesUsageDescription + O PhotoReport lê e guarda fotografias nas pastas de rede que escolheres. + + diff --git a/apps/desktop/src-tauri/tauri.conf.json b/apps/desktop/src-tauri/tauri.conf.json index a801d87..8dabd83 100644 --- a/apps/desktop/src-tauri/tauri.conf.json +++ b/apps/desktop/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "$schema": "https://schema.tauri.app/config/2", "productName": "PhotoReport", - "version": "0.3.19", + "version": "0.3.20", "identifier": "pt.photoreport.desktop", "build": { "devUrl": "http://localhost:5173", diff --git a/infra/desktop/build-macos.sh b/infra/desktop/build-macos.sh index ebea049..9e066b5 100755 --- a/infra/desktop/build-macos.sh +++ b/infra/desktop/build-macos.sh @@ -52,6 +52,41 @@ if [[ -n "${TAURI_SIGNING_PRIVATE_KEY:-}" && -n "${TAURI_UPDATER_PUBKEY:-}" ]]; # The bundler checks each signature against plugins.updater.pubkey, so the public key goes into the config too. extra=(--bundles dmg,app --config "$(node -e 'console.log(JSON.stringify({bundle:{createUpdaterArtifacts:true},plugins:{updater:{pubkey:process.env.PHOTOREPORT_UPDATER_PUBKEY}}}))')") fi +step "Code signing" +# macOS remembers the folders an app may open (Desktop, Documents, cards) by its signature. Unsigned, every build +# (and every update) looks like a new app and asks again, once per access. Signed always with the same identity, the +# answer is kept. With an Apple Developer ID set in APPLE_SIGNING_IDENTITY that one is used; otherwise a local +# identity, made once in the login keychain, the same for every build on this Mac. +if [[ -z "${APPLE_SIGNING_IDENTITY:-}" ]]; then + local_id="PhotoReport Local Signing" + if ! security find-identity -p codesigning | grep -q "\"$local_id\""; then + tmp="$(mktemp -d)" + cat >"$tmp/cert.cfg" </dev/null + /usr/bin/openssl pkcs12 -export -inkey "$tmp/key.pem" -in "$tmp/cert.pem" -name "$local_id" -out "$tmp/id.p12" -passout pass:photoreport + security import "$tmp/id.p12" -k "$HOME/Library/Keychains/login.keychain-db" -P photoreport -T /usr/bin/codesign + echo "macOS asks for your password once, to trust this certificate for signing:" + security add-trusted-cert -r trustRoot -p codeSign -k "$HOME/Library/Keychains/login.keychain-db" "$tmp/cert.pem" + rm -rf "$tmp" + fi + export APPLE_SIGNING_IDENTITY="$local_id" + # Not a Developer ID: no notarisation, so no hardened runtime (it would refuse the bundled ONNX library). + extra+=(--config '{"bundle":{"macOS":{"hardenedRuntime":false}}}') +fi +echo "Signing as: $APPLE_SIGNING_IDENTITY" + VITE_API_URL="$API" PHOTOREPORT_API_URL="$API" pnpm --filter @photoreport/desktop exec tauri build --target universal-apple-darwin "${extra[@]}" BUNDLE="apps/desktop/src-tauri/target/universal-apple-darwin/release/bundle" OUT="$BUNDLE/dmg" -- 2.47.3