我希望能够在我的原生macOS应用程序中 Select Xcode项目,我使用.xcodeproj
表示allowedContentTypes,但很明显Xcode或UniformTypeIdentifiers并不知道这一点!有没有办法让代码发挥作用?
import SwiftUI
import UniformTypeIdentifiers
struct ContentView: View {
@State private var fileImporterIsPresented: Bool = false
var body: some View {
Button("Select your Xcode projext") { fileImporterIsPresented = true }
.fileImporter(isPresented: $fileImporterIsPresented, allowedContentTypes: [.xcodeproj], allowsMultipleSelection: false, onCompletion: { result in
switch result {
case .success(let urls):
if let unwrappedURL: URL = urls.first {
print(unwrappedURL.path)
}
case .failure(let error):
print("Error selecting file \(error.localizedDescription)")
}
})
}
}