You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

MAUI FilePicker在MacCatalyst上返回null问题求助

MAUI FilePicker调用始终返回Null的问题求助

我遇到了MAUI FilePicker选择文件后返回Null的问题,与官方相关issue描述完全一致。已参考解决方案在Entitlements.plist中添加了以下权限:

<key>com.apple.security.files.user-selected.read-only</key>
<true/>

环境信息

开发机器(Windows)Dotnet工作负载:

Installed Workload Id Manifest Version Installation Source
---------------------------------------------------------------------
maui-windows 8.0.6/8.0.100 VS 17.10.34607.79
maccatalyst 17.2.8022/8.0.100 VS 17.10.34607.79
android 34.0.79/8.0.100 VS 17.10.34607.79
ios 17.2.8022/8.0.100 VS 17.10.34607.79 

发布机器(Mac)Dotnet工作负载:

Installed Workload Id Manifest Version Installation Source
---------------------------------------------------------------------
wasm-tools 8.0.2/8.0.100 SDK 8.0.200
macos 14.2.8022/8.0.100 SDK 8.0.200
maui-maccatalyst 8.0.6/8.0.100 SDK 8.0.200
maui-ios 8.0.6/8.0.100 SDK 8.0.200
maui-android 8.0.6/8.0.100 SDK 8.0.200
ios 17.2.8022/8.0.100 SDK 8.0.200
maui 8.0.6/8.0.100 SDK 8.0.200 

该问题已有获批合并的修复PR,2023年7月12日标记为已修复,但我在当前Visual Studio环境中未看到修复代码生效。

相关代码

项目为开源项目,以下是FilePicker相关代码:

Constants/FilePickerOptions.cs(第15&264行):

public static PickOptions TextFileOptions = new()
{
    PickerTitle = "Select a TXT file",
    FileTypes = TxtFile,
}; 

private static readonly FilePickerFileType TxtFile = new FilePickerFileType(
    new Dictionary<DevicePlatform, IEnumerable<string>>
    {
        { DevicePlatform.iOS, new[] { "public.text" } },
        { DevicePlatform.Android, new[] { "text/plain" } },
        { DevicePlatform.WinUI, new[] { ".txt" } },
        { DevicePlatform.Tizen, new[] { "*/*" } },
        { DevicePlatform.macOS, new[] { "public.text" } },
        { DevicePlatform.MacCatalyst, new[] { "public.text" } }
    });

Services/StorageContentFileService.cs(第51行):

var pickResult = await FilePicker.PickAsync(FilePickerOptions.TextFileOptions);

无论调用FilePicker.PickAsync还是FilePicker.Default.PickAsync,返回结果始终为Null。请问是否遗漏了必要操作或存在其他配置问题?


内容的提问来源于stack exchange,提问作者Onur Buyukcaglar

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.29 12:42:36