如何在swiftUI中使用FileImporter正确浏览文件?

如何在swiftUI中使用FileImporter正确浏览文件?,swift,swiftui,Swift,Swiftui,我是swiftUI新手,关于FIleImporter的信息很少。我目前正在将一个文件写入 let documentsPath = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0] let notesPath = documentsPath.appendingPathComponent("locations").appendingPathExtension("json&

我是swiftUI新手,关于FIleImporter的信息很少。我目前正在将一个文件写入

let documentsPath = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
let notesPath  = documentsPath.appendingPathComponent("locations").appendingPathExtension("json")
然后在我的ContentView上,我有一个按钮来浏览该目录的文件夹:

Button(action:{
                showingDirectory = true
            }){
                HStack{
                    Text("Browsed Saved Track")
                }
            }.fileImporter(isPresented: $showingDirectory, allowedContentTypes: [.json], allowsMultipleSelection: false){
                result in
            }
但是,当我运行代码时,文件broswer显示为空白,其中包含错误信息: [AXRuntimeCommon]未知客户端:分配4

我已确认该文件确实存在于: file:///Users/.../Library/Developer/CoreSimulator/Devices/.../data/Containers/Data/Application/D64B3041-7706-48C9-A6AE-9530DC074A86/Documents/locations.json

我认为可能的原因是文件浏览可能需要info.plist中的权限,但我不知道是哪一个,我尝试了


但是这些都不行,有人能帮我吗?谢谢

是macOS还是iOS?我相信这是iOS,这是iphone的Xcode项目