How to register a custom app opening URL scheme with Xcode 4?

openfrog picture openfrog · Nov 20, 2011 · Viewed 90k times · Source

Xcode4 is asking for a huge number of arguments just to make this simple thing possible:

NSString *stringURL = @"twitterriffic://";
NSURL *url = [NSURL URLWithString:stringURL];
[[UIApplication sharedApplication] openURL:url];

Xcode 4 Info.plist editor

What are all these properties for? Why an image? Must I repeat the app identifier here? What role to choose if I want anyone to be able to call this URL to open my app? And what are these Additional url type properties for?

I found no Xcode4-related tutorial how to register such an URL scheme with Xcode 4.

Answer

Mike S. picture Mike S. · Oct 8, 2012

Edit your AppName-Info.plist file

  • Open "Supporting Files" (folder) on left and click the "YourAppName-Info.plist"
  • Choose a row like "Bundle creator OS Type Code" and mouse over row and click the (+) symbol
  • This creates a new row and type "URL types"
  • Click the arror to left and see Item 0 and you'll rename the value in Item 0 to "URL Schemes" as shown
  • Then edit the field in Item 0 and type in your prototocol; I typed in "goomzee" as shown

Now if I install this app on my simulator, and open Safari and type "goomzee://" in the address bar it will launch my app.