I was able to execute a force press / 3D Touch on an app icon on an iPhone 7 running iOS 10.3. It was not possible on 10.2.
Objective-C
First you have to declare the following or import this header
typedef void (^CDUnknownBlockType)(void);
@interface XCEventGenerator : NSObject
+ (id)sharedGenerator;
// iOS 10.3 specific
- (double)forcePressAtPoint:(struct CGPoint)arg1 orientation:(long long)arg2 handler:(CDUnknownBlockType)arg3;
@end
And then execute the force press
XCUIElement *element = ...; // Get your element
XCUICoordinate *coord = [mapsIcon coordinateWithNormalizedOffset:CGVectorMake(0.5, 0.5)];
[[XCEventGenerator sharedGenerator] forcePressAtPoint:coord.screenPoint orientation:0 handler:^{}]; // handler cannot be nil
Here I execute a force press on the Maps icons.
Swift (not tested)
For Swift you have to declare/import the same interface/header as above and then execute the force press like this
let el = ...; // Get your element
let coord = el.coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.5) )
let eventGenerator: XCEventGenerator = XCEventGenerator.sharedGenerator() as! XCEventGenerator
eventGenerator.forcePress(at: coord.screenPoint, orientation: 0) { }