示例工程 53-appkit-bridging

53-appkit-bridging/Diagnostics/RepresentableWrongReturn.swift

swift · 0.3 KB

import AppKit
// 故意编译失败:makeNSView 必须返回 NSView,不能返回 Int。
// 复现:swiftc -typecheck Diagnostics/RepresentableWrongReturn.swift
import SwiftUI
 
struct V: NSViewRepresentable {
    func makeNSView(context: Context) -> NSView {
        42
    }
 
    func updateNSView(_ nsView: NSView, context: Context) {}
}