When my app (Lightwright) launches, one of the first things it does is try to create a folder within SpecialFolder.ApplicationData to do work in, store settings, etc. This has worked great for years on both Mac and Windows, but one of my users (a university) just reported that on macOS Big Sur Lightwright cannot create the folder. It only works if user has admin privileges, it fails for all other users. In this case, the app is running on a bunch of Macs in their computer lab.
Here’s the relevant code:
gLWAppDataFolder=SpecialFolder.ApplicationData.Child(kLWBundleIDStr) 'Note: kLWBundleIDStr is “com.mckernon.lightwright6”
If gLWAppDataFolder=Nil Then 'Something screwy is going on
If Not gLWAppDataFolder.Exists Then 'Try to create it
If gLWAppDataFolder=Nil Or Not gLWAppDataFolder.exists Then
MessageBox(kSorryStr+" Lightwright could not create a Temporary folder")
The user is getting the “could not create a Temporary folder” message. I’ve never had a user report this before, and I have other users who are happily running Lightwright on Big Sur.
Can anyone explain why this would be happening? How can I get it working? Is there some macOS magic I need to add for BS?
First thing is to check and make sure that the kLWBundleIDStr is exactly the bundle identifier for the application.
Secondly, I’d capture the path if possible, I recently discovered that Notarization cannot occur when the user folder is on a volume with a space in the drive name!
Thirdly, Capture the error code. IOExceptions rarly have a message, but nearly always have an error code.
Fourthly, capture the application version and system version in the error dialog. Here’s an example of how I would handle that function.
Dim errorMessage as string
gLWAppDataFolder = SpecialFolder.ApplicationData.Child( app.infoBundleIdentifier ) 'Note: kLWBundleIDStr is “com.mckernon.lightwright6”
If gLWAppDataFolder = Nil Then 'Something screwy is going on
ErrorMessage = "Unable to access"
elseif not gLWAppDataFolder.Exists Then 'Try to create it
Catch err as IOException
ErrorMessage = "Failed to create, code: " + str( err.errorNumber ) + " path: " + gLWAppDataFolder.nativePath
if errorMessage <> "" then
MessageBox kSorryStr + " ""Application Support"" folder issue occurred """ + errorMessage + """." + _
endOfLine + endOfLine + "Version: " + app.infoVersionString + endOfLine + _
"macOS Version: " + app.infoOSVersion
The more information you can capture the better, but shoesize doesn’t help!
A couple of months ago I had half a dozen reports about my app not starting correctly. Turned out that the app couldn’t write to Application Support. The users used the uninstaller, reinstalled and everything was okay. I got the reports within a day or two. And then the problem never showed up again. macOS…
And today I get this report from a user where the user doesn’t have access to the documents folder:
2021-07-04 14:27:58 An error happened:
2021-07-04 14:27:58 Class/Method: DefaultExportLocation.GetExportFolderNumbered
2021-07-04 14:27:58 Time: Sunday, July 4, 2021 2:27:58 PM Central Daylight Time 3923617
2021-07-04 14:27:58 Type of Error: IOException
2021-07-04 14:27:58 Error Number: 1
2021-07-04 14:27:58 Error Message: You don’t have permission to save the file “Mail Archiver X” in the folder “Documents”.
In App Wrapper, go to the Capabilities Page, under the files and folders heading, enter a “Usage message” next to the “Documents” folder. Then the user should be asked, next time they want to save files to the Documents folder.
What is unclear to me is exactly which “Usage Messages”, actually need to be filled. Sometimes you don’t need to fill it it, and sometimes you do, AppleScript YOU must fill in. I’d refer to Apple’s documentation, but it doesn’t always state and there’s no guarantee it’s up to date.
I am not 100% sure either, guessing is more like it.
Again, I’ll complain that it would be nice if we had documentation that made this clear and that we could trust, but that would eat into Apple’s profitability, so we flounder around like fish out of water instead.
Let me know if it does help.
Also talk to @Thomas_Tempelmann as he’s implemented a brilliant UI for aiding customers to enable Full Disk Access from your Mac application (Albeit you may need to use Twitter or e-mail to get ahold of him).