# Saving Files to Desktop no longer works (Sonoma)? Entitlements?

**URL:** <https://forums.solar2d.com/t/saving-files-to-desktop-no-longer-works-sonoma-entitlements/356604>\
**Category:** macOS Desktop\
**Created:** [June 22, 2024, 6:17am UTC](https://forums.solar2d.com/t/saving-files-to-desktop-no-longer-works-sonoma-entitlements/356604 "2024-06-22T06:17:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![yanko\_popov](https://forums.solar2d.com/user_avatar/forums.solar2d.com/yanko_popov/32/148_2.png) [@yanko\_popov](https://forums.solar2d.com/u/yanko_popov)\
**Post date:** [June 22, 2024, 6:17am UTC](https://forums.solar2d.com/t/saving-files-to-desktop-no-longer-works-sonoma-entitlements/356604/1 "2024-06-22T06:17:54Z")

</div>

Hello, I need some help. I have an apparent problem with entitlements on a silicone mac on MacOs Sonoma. The following sample code works without problems on the simulator, but not when build for macOS:

```auto
local path = system.pathForFile("hello_world.txt", system.DocumentsDirectory)

local file, errorString = io.open(path, "w")

if not file then
    print("File error: " .. errorString)
else
    file:write("hello world")
    io.close(file)
    print("File written successfully")
end

file = nil

local lfs = require("lfs")
local function moveFileToDesktop(fileName)
    local doc_path = system.pathForFile(fileName, system.DocumentsDirectory)
    local desktop_path = os.getenv("HOME") .. "/Desktop/" .. fileName

    local result, reason = os.rename(doc_path, desktop_path)
    if result then
        print("File moved to desktop successfully.")
    else
        print("Failed to move file: " .. reason)
    end
end

moveFileToDesktop("hello_world.txt")

```

I get this alert from my macOS app: “/Users/yankopopov/Library/Containers/FileSave/Data/Library/Application Support/FileSave/Documents/hello\_world.txt: Operation not permitted”. Apparently the file is created in the App’s sandbox Documents folder, but can not be copied to the desktop.

By the way these are the entitlements I’ve added to the build.settings file:

```auto
osx = {
    	entitlements = {
        	["com.apple.security.files.user-selected.read-write"] = true, -- get arbitrary access?
    	},
	},

```

I guess I need more or different entitlements, but I have no real idea… I’ve build the app with my credentials and provision profile as apple developer…  
Any ideas how to fix this? I would really appreciate any help.
