Ragnar Danneskjöld Ragnar Danneskjöld - 8 months ago 177
iOS Question

Unable to add Pass to Apple Wallet

I'm doing some testing with Apple Wallet. I've got a Pass I'd like to add to the user's Wallet when they tap a button. Here's my code:

let filePath = Bundle.main.path(forResource: "DealsPasses", ofType: "pkpass")!
let passData = try? Data(contentsOf: URL.init(fileURLWithPath: filePath), options: .alwaysMapped)
let pass = PKPass(data: passData!, error: nil)
let passVC = PKAddPassesViewController(pass: pass)
navigationController?.pushViewController(passVC, animated: true)

However; when the user tapps the button,

AX Exchange error: Error Domain=Accessibility Code=0 "Remote service does not respond to _accessibilityMachPort" UserInfo={NSLocalizedDescription=Remote service does not respond to _accessibilityMachPort}

is spammed to the console at a rate of ~200/min, and no PKAddPassesViewController is presented (or if it is, it's just got a plain white view)

Running xCode 8 on an iPhone SE (device)

(Side note: dragging the DealsPasses.pkpass into the simulator works just fine)


The problem turned out to be related to pushing the PKAddPassesViewController to the navigation controller's stack.

replacing navigationController?.pushViewController(passVC, animated: true) with present(passVC, animated: true, completion: nil) fixed the problem!