Last active
January 11, 2023 02:09
-
-
Save dfeinzimer/264740f19c216a68b64ebe4180cbc675 to your computer and use it in GitHub Desktop.
SwiftUI LibraryItem bug reproducer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ContentView.swift | |
// | |
// Created by David Feinzimer on 1/10/23. | |
// | |
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" | |
) | |
] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When passing an empty closure to a
LibraryItem
'ssnippet
parameter, unexpected extra text is added to the file when the item is dragged in from the Xcode library.Expected:
Actual:
macOS 13.0.1 (22A400)
Xcode 14.1 (14B47b)