77

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.

2

4 Answers 4

98

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.

3
  • 4
    Within the .plist file, the relevant code is: <key>CFBundleURLTypes</key> <array> <dict> <key>CFBundleURLSchemes</key> <array> <string>goomzee</string> </array> </dict> </array> Apr 21, 2013 at 13:17
  • 6
    <key>CFBundleURLTypes</key> <array> <dict> <key>CFBundleURLName</key> <string>com.iphonebasic.testdemo</string> <key>CFBundleURLSchemes</key> <array> <string>com-iphonebasic-testdemo</string> </array> </dict> </array>
    – 9to5ios
    May 23, 2013 at 7:46
  • @Mike S. I tried the steps you provided, it fade away when I move from Info.plist to other tab. May 17, 2017 at 7:08
29

Yup, this stuff isn't straightforward is it ?

I've outlined the steps required to register a custom URL here: Custom URLs

But, basically the key to it is setting up a "URL Types" value in your .plist file. Here's what it looks like in XCode 5:

URL types

In this example, I've registered the MKB prefix, so now, I can use this new type of URLs in hyperlinks on webpages, and emails (if I read an email in the iPad Mail app):

Mail app

If a user taps on one of these links, my iPad app will start up, and I can access the full URL string, to extract the other parameters from the URL (eg "DocumentNumber=100")

The only gotcha is that I have yet to work out how to test whether a user has an iPad app installed which can recognise a particular prefix.

If they haven't, and they tap on one of these MKB:// links on their iPad, they'll get an ugly error message:

Nope

2
  • 1
    Wow fantastic explanation on your blog. This saved me about 2 hours. THANK YOU!!
    – Wirsing
    Mar 28, 2014 at 7:07
  • The thing is that AFTER MKB:// there MUST be anything. May 11, 2017 at 4:33
17

You can continue to register your custom URL by editing your app's info.plist file (as shown in one of your previous questions). The new editor in Xcode 4 is supposed to be a convenience to make it easier to add the entries - all it is doing is making the same info.plist changes that you would do manually. If you want to use the new editor then you only need to fill in the 'Identifier' and the 'URL Schemes' boxes. You don't need an image, icon or additional URL properties.

The other properties (icon etc) are not well documented but seem to be applicable only on Mac OS X and might be used in the Finder's Get Info dialog to display what types of URL a particular app can open. For example, take a look at the Launch Services Programming Guide.

0

What you change in that editor is also reflected in your project's info plist file. It takes the form of ProjectName-Info.plist. Hopefully that helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.