struct ContentView: View {
   @State private var pastedText = ""

   var body: some View {
      VStack {
         HStack {
            Button("Copy") {
               #if os(macOS)
               let clip = NSPasteboard.general
               clip.clearContents()
               clip.setString("Hello, World!", forType: .string)
               #else
               let clip = UIPasteboard.general
               clip.string = "Hello, World!"
               #endif
            }.buttonStyle(.glass)
            Button("Paste") {
               #if os(macOS)
               let clip = NSPasteboard.general
               let text = clip.string(forType: .string)
               pastedText = text ?? "The clipboard is empty"
               #else
               let clip = UIPasteboard.general
               pastedText = clip.string ?? "The clipboard is empty"
               #endif
            }.buttonStyle(.glassProminent)
         }
         Text(pastedText)
            .padding()
      }.padding()
   }
}