mrmabx mrmabx - 3 months ago 57
Swift Question

LSApplicationQueriesSchemes and derived data

I would like to open a whatsapp url in my app like.

let whatsAppUrl = NSURL(string: "whatsapp://send?text=Hello%2C%20World!")
if UIApplication.sharedApplication().canOpenURL(whatsAppUrl!) {

I extend my info.plist with a dictionary "LSApplicationQueriesSchemes" and add my url scheme for whatsapp.

<key>Item 0</key>

If i run my app i get the following error message.

"This app is not allowed to query for scheme whatsapp"

I read some solutions with cleaning the derived data and run the app again to fix this issue. But this not help me, exists an other solution for my issue?


You have made the LSApplicationQueriesSchemes a dict, it must be an array, like this, then it will work :).


And I would also recommend you to not unwrap the optional URL using !, you can do it like this instead:

guard let whatsAppUrl = NSURL(string: "whatsapp://send?text=Hello%2C%20World!") else { return }

if UIApplication.sharedApplication().canOpenURL(whatsAppUrl) {