Universal Links Logo

URL Schemes -Getting Started

This entry is part 4 of 12 in the series Universal Links

We have three URL schemes that we’ll be adding to our example apps. We don’t need to do anything with the Web server. Everything here will be done on the applications, themselves, in Xcode.

Here is a release that has the starting point code.

Setting Up the Info.plist File

This section applies to all three targets.

In Xcode 15, we don’t need to manipulate the Info.plist file directly. Xcode has a UI that handles it.

Step One – Edit the Info Section of the Target Panel

In Xcode, select the project, then the target (We’ll show you how to do it for the App Delegate Target, but you should do the same for the other two targets):

Next, open the Info section, and open “URL Types”:

Now, we add a new URL type, and give it a URL Scheme of "iul1" (For the App Delegate app). Leave the Role as “Editor”:

Now, run the target on the simulator. Stop it, after it opens.

Try opening that same URL in Safari again. You’ll see a different behavior, this time:

Note that the “?go” does nothing. That’s our next step.

If you were to look at the Info.plist file for the target, you would see the following:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>CFBundleURLTypes</key>
	<array>
		<dict>
			<key>CFBundleTypeRole</key>
			<string>Editor</string>
			<key>CFBundleURLSchemes</key>
			<array>
				<string>iul1</string>
			</array>
		</dict>
	</array>
</dict>
</plist>

That “CFBundleURLTypes” dictionary is new. It was added by the step we just did.

Now, do the same for each of the other two targets (“iul2” for the Scene Delegate target, and “iul3” for the SwiftUI target).

Here is the release that has the URL Schemes added.

OK. Now it’s time to roll up our sleeves, and get our hands dirty. Onward and Upward…