When passing an empty closure to a LibraryItem
's snippet
parameter, unexpected extra text is added to the file when the item is dragged in from the Xcode library.
Expected:
.setAction {
}
Actual:
.setAction /*@START_MENU_TOKEN@*/{
}/*@END_MENU_TOKEN@*/
Full code:
import SwiftUI
struct ContentView: View {
var body: some View {
MyView()
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
struct MyView: View {
var action: (() -> Void)?
var body: some View {
Text("MyView")
.onTapGesture {
action?()
}
}
func setAction(_ action: @escaping () -> Void) -> MyView {
var copy = self
copy.action = action
return copy
}
}
struct LibraryContent: LibraryContentProvider {
func modifiers(base: MyView) -> [LibraryItem] {
[
LibraryItem(
base.setAction {
},
title: "MyView - Set action"
)
]
}
}
FB11936092
macOS 13.0.1 (22A400)
Xcode 14.1 (14B47b)