0

I am working on custom keyboard extension app with Xcode 8.2.1 and Swift3. I want to paste an Image to UIPasteboard in swift. I am using the following code.

let image = UIImage(named: imageName) UIPasteboard.general.image = image;

But I am getting the following error.
Could not save pasteboard named com.apple.UIKit.pboard.general. Error: Error Domain=PBErrorDomain Code=7 "Cannot connect to pasteboard server."

Kindly help me how can I resolve this issue?
P.S It is working perfectly on simulator.

Shahid Iqbal
  • 2,059
  • 2
  • 21
  • 29

1 Answers1

2

Apple restricts access to the pasteboard by default with keyboard extensions. You need to allow Full Access under Settings. To be able to enlist for, and grant, full access see this answer to a similar question https://stackoverflow.com/a/25978977/3413035.

Community
  • 1
  • 1
Stephen
  • 172
  • 2
  • 8