2

I'm currently creating a raycast extension for quickly opening recently opened Pages documents. Now, I have to find a way to access the documents and their pathnames. I tried following this answer and stumbled across ~/Library/Containers/com.apple.iWork.Pages/Data/Library/Preferences/com.apple.iWork.Pages.plist. This plist file contains a key named TSARecentOpenedDocumentTimestamps which corresponds to an array of timestamps of when I opened pages documents.

However, when using Xcode's built inplist search tool, I could not find any arrays of recently opened file paths or names. I also tried renaming the file to com.apple.iWork.Pages.old.plist and then quit and reopened pages. After it opened, I was faced with the "welcome to pages" screen, like when I first opened it after getting my MacBook. However, I tried going to file -> open recent in the menu bar and found that my recently opened file names were still there, but greyed out. Therefore, the recently opened files could not have been stored in that plist.

A raycast extension exists for opening recently opened Visual Studio Code projects, so I forked the code to see how. It reads from a database located at ~/Library/Application Support/Code/User/globalStorage/state.vscdb with the following SQL query SELECT json_extract(value, '$.entries') as entries FROM ItemTable WHERE key = 'history.recentlyOpenedPathsList'. However, while trying to find a similar file for pages, I noticed that it does not even have a folder in ~/Library/Application Support with its data.

I have absolutely no idea where Pages could store this data, and without knowing where, I can't build this extension. So does anyone know where this data is stored? Thanks in advance!

1 Answer 1

2

Native Mac applications delegate this functionality to Apple's frameworks.

AppKit and NSDocumentController

For document based Mac applications, recent documents are handled by Apple's AppKit NSDocumentController class. Applications can call the NSDocumentController recentDocumentsURLs method to access this list.

This means the list is managed by macOS and is not expected to be read directly.

Launch Services

Below NSDocumentController, the recent documents are managed by Launch Services:

macOS Launch Services is an API that enables a running app to open other apps or their document files, similar to the Finder or the Dock. Using Launch Services, an app can perform such tasks as:

  • ...
  • Maintain and update the contents of the Recent Items menu

See sharedfilelistd and sfltool for related commands.

com.apple.sharedfilelist

Listed in the related files section of sharedfilelistd's manual page is this file pattern:

ls ~/Library/Application\ Support/com.apple.sharedfilelist/*

These files store the recent documents per application. They appear to be encoded by NSCoder and written as a Binary Property List files. Passing a file to the file command confirms the base format of Apple binary property list.

3
  • Thanks, I found the file ~/Library/Application Support/com.apple.sharedfilelist/com.apple.LSSharedFileList.ApplicationRecentDocuments/com.apple.iwork.pages.sfl2 However, sfltool is failing when I try to archive the file and outputs: CFURLCopyResourcePropertyForKey failed because it was passed a URL which has no scheme. What exactly is an NSEncoded property list? I know what a standard property list is, but I don't know how to decode it or turn it into a standard Plist Oct 1 at 12:48
  • Sorry, but the documentation wasn't that helpful for me because I know absolutely nothing about objective-c. How can I decode the file by making an NSCoder in the terminal? The pmutil command did work by the way, but the file is pretty useless until I figure out how to decode it. Oct 1 at 13:26
  • 1
    Thanks for the help, I created the new question. apple.stackexchange.com/questions/464870/how-to-decode-nscoder Oct 1 at 17:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .