I am recently developing a Document-Based App by Xcode v13.1
I find there is some unexpected messages output in the console as below
2022-07-14 18:18:22.182714+0800 TestApp[31090:987991] [default] Failed to get state for list identifier com.apple.LSSharedFileList.ApplicationRecentDocuments Error: Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted" (Access to list denied) UserInfo={NSDebugDescription=Access to list denied}
...
2022-07-14 18:19:28.460021+0800 TestApp[31090:988415] [default] Insert failed for list identifier com.apple.LSSharedFileList.ApplicationRecentDocuments Error: Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted" (Access to list denied) UserInfo={NSDebugDescription=Access to list denied}
By testing, I find a problem that the recently opened is unavailable on my App, (App Menu > File > Open Recent sub-menu is always empty)
As makabaka1880 said in the thread https://developer.apple.com/forums/thread/707260, it is a trigger to set Signing Certificate from Development to Sign to Run Locally
Therefore, we can avoid this kind of problem via one of the following temporary solutions:
removing the App Sandbox
keeping Signing Certificate being Development
changing the Bundle Identifier to the other available
Go deeper. How can we solve the problem fundamentally?
According the description of makabaka1880, we can conclude that the Failed Bundle Identifier has be recorded in somewhere not in the project folder.
By turning over the folder ~/Library/ using find and grep, removing non essential documents, especially whose name is similar to LSSharedFileList, even using the defaults command to delete relative App information, the problem is still unsolved.
Finally, I find a document about the sharedfilelist:https://eclecticlight.co/2017/08/10/recent-items-launch-services-and-sharedfilelists/
There is a command quoted in the document:
killall sharedfilelistd
To stop the process can ensure that the Failed Bundle Identifier record is not existing on memory.
By way of practice, another necessary operation is to remove relative data in the hard disk.
Here is the finally solution can be executed on console:
rm -rf ~/Library/Application\ Support/com.apple.sharedfilelist/ && killall sharedfilelistd