Even setting the pasteboard fails:
class AppDelegate: NSObject, NSApplicationDelegate {
func applicationDidFinishLaunching(_ aNotification: Notification) {
let prevClipboard: String = NSPasteboard.general.string(forType: .string) ?? ""
print("prev: \(prevClipboard)") // returns "string 1"
// modify clipboard from "string 1" to "string 2"
NSPasteboard.general.setString("string 2", forType: .string)
let newClipboard: String = NSPasteboard.general.string(forType: .string) ?? ""
print("prev: \(newClipboard)") // returns "string 1" (not "string 2" as it should, thus it shows i am unable to modify the clipboard)
}
}