Post

Replies

Boosts

Views

Activity

Reply to Sandboxed Electron macOS app can't access Photos library
Hi Quinn, Thank you so much for your reply! I created the demo app as you suggested and I did notice an issue. In my failing main app, I didn't enable Hardened Runtime. By enabling the Hardened Runtime, the main app simply crashes after launch for some reason. I am wondering if it is mandatory to have Hardened Runtime in order to access the Photos library in a Sandboxed app? In Xcode, the UI seems already tell me that it is required, but I am wondering if you could confirm it.
Aug ’24
Reply to Sandboxed Electron macOS app can't access Photos library
I started over by creating a minimal Electron app to better narrow down the issue. It seems Hardened Runtime is not the root cause. As long as the 'com.apple.security.app-sandbox' entitlement is enabled, my app cannot communicate with the Photos library, regardless of whether Hardened Runtime is on or off. However, it starts working again once I disable the sandbox. In my use case, the main process loads a dylib (Node.js native addon) during runtime, and I believe it uses dlopen to load the library. I can confirm that the library is successfully loaded, as that's where the PHAuthorizationStatus: Authorized log comes from, but for some reason, it can't communicate with photolibraryd and print the XPC errors instead. I am wondering if there is anything else I can check to help reveal the root cause. Thanks for your help @DTS Engineer !
Aug ’24
Reply to Sandboxed Electron macOS app can't access Photos library
Hi Quinn, even though I still don't understand the root cause, I was able to tell that the problem seems to be related to the Electron framework itself. Would you mind update the title of this post by adding "Electron" to it? For anyone who are building Mac App Store apps with Electron and met similar XPC errors, it seems the issue has been addressed since Electron v26. Electron 25.9.8 with Node 18.15.0: Doesn't work Electron 26.0.0 with Node 18.16.1: Works fine
Aug ’24
Reply to Mac App Store / TestFlight installs app to random folders
I am using the following script to unregister my apps from the Launch Services. Thank you for your help, Quinn! #!/bin/bash # List of app names to unregister from Launch Services names="Electron.app|MyApp.app" # Function to unregister an app unregister_app() { local path="$1" echo "Unregistering: $path" /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -u "$path" } # Run lsregister -dump and grep for specific apps, then process each line /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -dump | grep -E "$names" | while IFS= read -r line; do # Extract the app path path=$(echo "$line" | cut -c 6- | rev | cut -c 10- | rev | xargs) # Check if path is not empty if [ ! -z "$path" ]; then unregister_app "$path" fi done echo "Unregistration process completed."```
Sep ’24