示例工程 41-system-integration

41-system-integration/Diagnostics/ImporterStringTypes.swift

swift · 0.4 KB

// 故意编译失败:allowedContentTypes 是 [UTType],不是 [String]。
// 复现:swiftc -typecheck Diagnostics/ImporterStringTypes.swift
import SwiftUI
 
struct Bad: View {
    @State private var showing = false
 
    var body: some View {
        Color.clear.fileImporter(
            isPresented: $showing,
            allowedContentTypes: ["public.text"]
        ) { _ in }
    }
}