Simulating Apple pencil in the simulator seems to be possible somehow

2.9k Views Asked by At

I was wondering if it is possible to simulate the Apple pencil in the iOS simulator.

According to an Apple emloyee here Xcode iOS Simulator: can I use the mouse as pretend Apple Pencil input (on iPad Pro), for testing? it is not possible. And the answer was given in June 2017.

According to https://developer.xamarin.com/guides/cross-platform/windows/ios-simulator/ (very last paragraph: Stylus support in Windows is also translated to Apple Pencil input on the simulator.), using the remote iOS simulator from Xamarin, it is possible to simulate the pencil. (and they have had this feature for some months already)

So, I am a bit confused. As far as I know, Xamarin uses the normal iOS simulator, too. (They just show it via a remote connection on a Windows PC) If they have pencil support in the simulator, it must be possible for anybody, mustn't it?

1

There are 1 best solutions below

0
On

For those who stuck with this in 2021 try the following:

iOS 14

#if targetEnvironment(simulator)
canvasView.drawingPolicy = .anyInput
#else
canvasView.drawingPolicy = .pencilOnly
#endif

Also in the Settings app there is a global setting called "Only Draw with Apple Pencil". This can be read from UIPencilInteraction.prefersPencilOnlyDrawing in PencilKit.

iOS 13 (only)

#if targetEnvironment(simulator)
canvasView.allowsFingerDrawing = true
#else
canvasView.allowsFingerDrawing = false
#endif

Courtesy of https://stackoverflow.com/a/62567169/2667933