When installing the Explr application from a DMG file on macOS, the app would launch as a background service instead of displaying the frontend user interface. This is a common issue with Tauri applications on macOS due to improper Launch Services configuration.
- App appears to launch (visible in Activity Monitor)
- No window or user interface appears
- App runs in the background without user interaction capability
- Users cannot access the file explorer functionality
The issue occurred because the macOS Launch Services didn't properly recognize the Tauri app as a standard GUI application. Specifically:
- Missing Info.plist Configuration: The app bundle's Info.plist lacked proper keys to identify it as a foreground application
- Launch Environment Issues: The app wasn't receiving the proper environment variables that GUI applications expect on macOS
- Bundle Signing: Changes to the app bundle required re-signing to take effect
-
Project Structure Analysis
- Examined
src-tauri/tauri.conf.jsonfor macOS-specific configurations - Reviewed Rust main.rs for frontend initialization code
- Created automated post-build script system
- Examined
-
Build Artifact Investigation
- Found built DMG files in
target/aarch64-apple-darwin/release/bundle/dmg/ - Discovered that app bundles were being cleaned up after DMG creation
- Identified the need to extract and fix the app bundle
- Found built DMG files in
-
App Bundle Extraction
# Mount existing DMG hdiutil attach target/aarch64-apple-darwin/release/bundle/dmg/Explr_0.2.3_aarch64.dmg # Copy app bundle to working directory cp -R /Volumes/file-explorer/file-explorer.app target/aarch64-apple-darwin/release/bundle/macos/ # Unmount DMG hdiutil detach /Volumes/file-explorer
-
Launch Fix Implementation
- Binary Wrapper Creation: Created a shell script wrapper that simulates proper terminal environment
- Info.plist Updates: Modified app bundle's Info.plist to include required Launch Services keys
- Re-signing: Applied code signing to ensure changes take effect
-
Automated Build Integration
- Integrated fixes into post-build script
- Created universal build system for both architectures
-
Post-Build Script Creation (
src-tauri/scripts/post-build.sh)- Automatically detects macOS builds
- Extracts app from DMG if necessary
- Applies all launch fixes automatically
- Creates fixed DMG for distribution
-
Package.json Integration
{ "scripts": { "tauri:build": "cargo tauri build && cd src-tauri/scripts && ./post-build.sh", "tauri:build:macos": "cargo tauri build --target aarch64-apple-darwin && cd src-tauri/scripts && ./post-build.sh", "build:all": "npm run build && npm run tauri:build:macos" } } -
Comprehensive Build Script (
build.sh)- Full build automation with colored output
- Platform detection and appropriate build steps
- Clear indication of which artifacts to distribute
The fix adds/modifies these keys in the app's Info.plist:
<key>LSUIElement</key>
<false/>
<key>LSBackgroundOnly</key>
<false/>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>Created at Contents/MacOS/src-tauri (original binary renamed to src-tauri-real):
#!/bin/bash
# macOS Launch Services Fix - Simulates terminal environment
export TERM="xterm-256color"
export TERM_PROGRAM="Apple_Terminal"
export SHELL="/bin/zsh"
export XPC_FLAGS="0x0"
export XPC_SERVICE_NAME="0"
export __CFBundleIdentifier="com.apple.Terminal"
# Complete PATH
export PATH="/Library/Frameworks/Python.framework/Versions/3.11/bin:/opt/local/bin:/opt/local/sbin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin"
cd "$(dirname "$0")"
exec ./src-tauri-real "$@"src-tauri/scripts/post-build.sh- Automated post-build macOS fix scriptbuild-universal.sh- Universal build script for both Apple Silicon and IntelMACOS_FRONTEND_FIX.md- This documentation file
package.json- Streamlined build scripts for universal buildingsrc-tauri/tauri.conf.json- Added macOS-specific configuration options
target/aarch64-apple-darwin/release/bundle/dmg/Explr_0.2.3_aarch64.dmg- Original DMGtarget/aarch64-apple-darwin/release/bundle/dmg/file-explorer_fixed_0.2.3_aarch64.dmg- Fixed DMG (USE THIS FOR DISTRIBUTION)target/aarch64-apple-darwin/release/bundle/macos/file-explorer.app- Fixed app bundle
# Build with automatic macOS fixes
npm run build:all
# Or step by step
npm run build # Build React frontend
npm run tauri:build:macos # Build Tauri app + apply fixes# Use the comprehensive build script
./build.shgraph TD
A[Start Build] --> B[Install Dependencies]
B --> C[Build React Frontend]
C --> D[Build Tauri App]
D --> E{Is macOS?}
E -->|Yes| F[Extract App from DMG]
E -->|No| K[Build Complete]
F --> G[Apply Launch Fixes]
G --> H[Update Info.plist]
H --> I[Create Wrapper Script]
I --> J[Re-sign App Bundle]
J --> L[Create Fixed DMG]
L --> M[Build Complete with Fix]
- Build the application using the new build process
- Install the fixed DMG (
file-explorer_fixed_0.2.3_aarch64.dmg) - Launch the app from Finder or Spotlight
- Verify that the frontend interface appears correctly
- Test all application functionality
- ✅ App launches and displays frontend interface
- ✅ All file explorer features work correctly
- ✅ No background-only behavior
- ✅ App appears in Dock when running
- ✅ App can be quit normally
-
"App not found" during post-build script
- Ensure the build completed successfully
- Check that the DMG was created in the expected location
-
Permission denied on scripts
chmod +x build.sh chmod +x src-tauri/scripts/post-build.sh chmod +x src-tauri/fix-macos-launch.sh
-
App still launches in background
- Ensure you're using the fixed DMG (
*_fixed_*.dmg) - Try clearing Launch Services cache:
sudo /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user
- Ensure you're using the fixed DMG (
-
Code signing issues
- The fix uses self-signing (
-) which works for local development - For distribution, replace with proper signing identity
- The fix uses self-signing (
If issues persist, check these files:
target/aarch64-apple-darwin/release/bundle/macos/file-explorer.app/Contents/Info.plisttarget/aarch64-apple-darwin/release/bundle/macos/file-explorer.app/Contents/MacOS/src-tauri(should be wrapper script)target/aarch64-apple-darwin/release/bundle/macos/file-explorer.app/Contents/MacOS/src-tauri-real(should be original binary)
- Proper Code Signing: Integrate with Apple Developer certificates for distribution
- Notarization: Add notarization step for macOS Gatekeeper compatibility
- Universal Binaries: Build both x86_64 and aarch64 versions
- Automated Testing: Add automated tests to verify frontend launches correctly
- CI/CD Integration: Integrate fix into GitHub Actions or similar CI/CD pipelines
- v1.0 (Current) - Initial implementation with manual and automated fixes
- v1.1 (Planned) - Integration with proper code signing and notarization
For issues related to this fix:
- Check this documentation first
- Verify you're using the fixed DMG file
- Test with a clean macOS installation if possible
- Check the build logs for any error messages during the post-build script execution
*_fixed_*.dmg) to end users, not the original DMG. The fixed version includes all necessary modifications for proper frontend display on macOS.