I’m making an attempt to create a duplicate button for an iOS Widget utilizing AppIntent
.
Right here is my code:
struct CopyTextIntent: AppIntent {
static var title: LocalizedStringResource = "Copy Useful resource"
static var isDiscoverable: Bool { false }
var useful resource: String
init(useful resource: String) {
self.useful resource = useful resource
}
init() {
self.useful resource = "'_'/"
}
func carry out() async throws -> some ReturnsValue<String> {
let pasteboard = UIPasteboard.common
pasteboard.string = useful resource
return .outcome(worth: useful resource)
}
}
After I use this on my widget and click on on it, it both silently fails or throws this error:
saving pasteboard failed with error: Error Area=PBErrorDomain Code=11 “The pasteboard identify com.apple.UIKit.pboard.common just isn’t legitimate.” UserInfo={NSLocalizedDescription=The pasteboard identify com.apple.UIKit.pboard.common just isn’t legitimate.}
I’m making an attempt to repeat my widget’s string to UIPasteboard
however it is not working.