Xcode iOS Simulator: can I use the mouse as pretend Apple Pencil input (on iPad Pro), for testing?
Asked Answered
A

2

7

Is it possible to do this (with a menu, a shortcut, or a modifier key + mouse)?

For example, you can use the mouse to test simple touch gestures in the simulator, like left mouse acts as single finger, and shift / option allow for different two finger gestures.

I have been unable to find any documentation one way or the other about whether this is possible, despite this developer.apple.com page where the simple, easy-to-understand API changes for supporting Apple Pencil hardware are documented.

Do I need a physical iPad Pro + Pencil hardware to test my Pencil support?

(My app is not a drawing app, just an app where touch input should work with large touch targets and Pencil should allow finer distinctions.)

Anemograph answered 19/6, 2017 at 20:13 Comment(0)
I
1

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://mcmap.net/q/1622023/-ios-pencilkit-not-drawing

Involute answered 18/5, 2021 at 15:19 Comment(1)
This will work for some but not all of Apple Pencil features, i.e., only the ones that are shared with finger touches. Things like azimuth will not be available with this method. Having said that, it's a good solution for many applications.Goodman
M
7

The Simulator does not currently support simulating Apple Pencil input. We are aware people would like to do this.

Mandrel answered 28/6, 2017 at 6:30 Comment(3)
Why is it possible to use the Xamarin iOS remote simulator with support for pencil? See here stackoverflow.com/questions/45451739Thrift
I can't comment on third-party products.Mandrel
Do you mean, you are not allowed to, or you are not able to?Thrift
I
1

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://mcmap.net/q/1622023/-ios-pencilkit-not-drawing

Involute answered 18/5, 2021 at 15:19 Comment(1)
This will work for some but not all of Apple Pencil features, i.e., only the ones that are shared with finger touches. Things like azimuth will not be available with this method. Having said that, it's a good solution for many applications.Goodman

© 2022 - 2024 — McMap. All rights reserved.