The AiMessage app runs in a macOS sandbox, which prevents it from directly accessing the Messages database at ~/Library/Messages/chat.db. This is by design for security - sandboxed apps can only access files the user explicitly grants permission to.
Since direct database access isn't possible from a sandboxed app, we've implemented a hybrid approach:
When users click "Export Messages Now", the app:
- Creates an export script (
export_imessages.sh) on the Desktop - Opens Terminal automatically with the script
- The script runs outside the sandbox with proper permissions
- Click "Export Messages Now" in AiMessage
- Terminal opens with the export script
- Run the script (it will check for Full Disk Access)
- The script exports messages to a CSV file on Desktop
- Drag the CSV file back into AiMessage to import
- App remains sandboxed (safer for users)
- No need to disable app sandboxing
- Users maintain control over their data
- Clear visibility into what's being exported
- macOS prevents sandboxed apps from accessing Messages database
- Full Disk Access must be granted to Terminal, not the app
- Running shell commands from sandboxed apps has limited permissions
- Disable Sandboxing - Would work but compromises security
- AppleScript - Also blocked by sandbox for Messages access
- Shortcuts App - Requires manual shortcut creation by users
- Direct SQLite Access - Blocked by sandbox permissions
If you're building from source and want direct export:
- Disable app sandboxing in entitlements (not recommended)
- Or use the current script-based approach
- Or implement a non-sandboxed helper tool (complex)
- Investigate using XPC services for privileged operations
- Consider Apple's App Groups for shared data access
- Explore Messages framework APIs (if Apple provides them)
- Grant Terminal Full Disk Access in System Settings
- Restart Terminal after granting access
- Make sure script has execute permissions
- Check that Messages app has been used on this Mac
- Verify Messages database exists at
~/Library/Messages/chat.db - Try closing Messages app before exporting