The idea is to make an app that can send a 'tap the screen at coordinates (x,y)' event continuously in the background of another app in iOS. Think of a 'Cookie Clicker' cheat. I am currently assisting my friends in his app, and my job is to attempt to bug it out as much as possible. I have a slight feeling that tapping one of his buttons as much as possible will bug out his app, thus why I'm here.
The method is using KIF along with the background execution in iOS to achieve this.
In one of the classes, the file KIFUITestActor.m has the code:
- (void)tapScreenAtPoint:(CGPoint)screenPoint { [self runBlock:^KIFTestStepResult(NSError **error) { // Try all the windows until we get one back that actually has something in it at the given point UIView *view = nil; for (UIWindow *window in [[[UIApplication sharedApplication] windowsWithKeyWindow] reverseObjectEnumerator]) { CGPoint windowPoint = [window convertPoint:screenPoint fromView:nil]; view = [window hitTest:windowPoint withEvent:nil]; // If we hit the window itself, then skip it. if (view != window && view != nil) { break; } } KIFTestWaitCondition(view, error, @"No view was found at the point %@", NSStringFromCGPoint(screenPoint)); // This is mostly redundant of the test in _accessibilityElementWithLabel: CGPoint viewPoint = [view convertPoint:screenPoint fromView:nil]; [view tapAtPoint:viewPoint]; return KIFTestStepResultSuccess; }]; }
Would this be the code I'm looking for, and how would I implement it in Swift? (Or Objective-C if it makes things easier?)
- Would running the class as a background service achieve the background execution?
Many thanks if you can answer this question.