mauimac-catalyst

MAUI File picker Operation not permitted on MacOS


When I try to select a file in a FilePicker on MAUI I get an error even with the environments.plist updated as required in the MAUI documentation

Error message : 2024-06-11 11:53:58.471 ProjectManagement[50242:2538916] Failed to create an FPSandboxingURLWrapper for file:///Users/name/Downloads/insert.csv. Error: Error Domain=NSPOSIXErrorDomain Code=1 "couldn't issue sandbox extension com.apple.app-sandbox.read-write for '/Users/name/Downloads/insert.csv': Operation not permitted" UserInfo={NSDescription=couldn't issue sandbox extension com.apple.app-sandbox.read-write for '/Users/name/Downloads/insert.csv': Operation not permitted}

Method for file picker

public static async Task InsertAsync()
        {
            var options = new PickOptions
            {
                PickerTitle = "Sélectionnez un fichier CSV"
            };
            var file = await FilePicker.PickAsync(options);


            if (file != null)
            {
                ...
            }
        }

Environmen.plist with keys

<dict>
    <key>com.apple.security.app-sandbox</key>
    <true/>
    <key>com.apple.security.network.client</key>
    <true/>
    <key>com.apple.security.assets.movies.read-only</key>
    <true/>
    <key>com.apple.security.assets.music.read-only</key>
    <true/>
    <key>com.apple.security.assets.pictures.read-only</key>
    <true/>
    <key>com.apple.security.files.downloads.read-only</key>
    <true/>
    <key>com.apple.security.files.user-selected.read-only</key>
    <true/>
    <key>com.apple.security.personal-information.photos-library</key>
    <true/>
    <key>com.apple.app-sandbox.read-write</key>
    <true/>
</dict>

I've also tried to add com.apple.app-sandbox.read-write and com.apple.security.files.user-selected.read-only in the environment.plist however the operation is still not permitted...


Solution

  • Adding <key>com.apple.security.files.user-selected.read-write</key> <true/> in Environmen.plist solved the problem