UIPopoverPresentationController should have a non-nil sourceView or barButtonItem set before the presentation occurs on iOS 9

You can create a popover presentation controller like this also and it may work – (IBAction)showPopup:(UIButton *)sender { ViewController *contentViewController = [[ViewController alloc] init]; contentViewController.preferredContentSize = CGSizeMake(200, 200); contentViewController.modalPresentationStyle = UIModalPresentationPopover; UIPopoverPresentationController *popoverpresentationController = contentViewController.popoverPresentationController; popoverpresentationController.delegate = self; popoverpresentationController.permittedArrowDirections = UIPopoverArrowDirectionUp; popoverpresentationController.sourceRect = sender.bounds; popoverpresentationController.sourceView = sender; [self presentViewController:contentViewController animated: YES completion: nil]; }

Xcode7 | Xcode UI Tests | How to handle location service alert?

Xcode 9 let springboard = XCUIApplication(bundleIdentifier: “com.apple.springboard”) let allowBtn = springboard.buttons[“Allow”] if allowBtn.exists { allowBtn.tap() } Xcode 8.3.3 _ = addUIInterruptionMonitor(withDescription: “Location Dialog”) { (alert) -> Bool in alert.buttons[“Allow”].tap() return true } app.buttons[“Request Location”].tap() app.tap() // need to interact with the app for the handler to fire Note that it is a bit different as … Read more