Course outline

iOS / Swift / Accessible systems and target evidence / Lesson 21

Universal Link association and safe routing

Connect a domain and iOS app through associated domains while validating incoming URLs and authorizing records separately.

About 3 min readContent reviewed
On this page

Lesson goals

  • Explain the app and website association.
  • Identify the signed entitlement and domain statement.
  • Validate incoming links and authorize requested data.

Define the association

Universal Links connect supported website URLs to an app through an association between the signed application and the domain. The app declares an associated-domain entitlement and the site serves an association file identifying the app and permitted URL patterns. Use a domain you control and the actual app identifier for the signed artifact. This association does not authenticate a person or authorize a record.

Declare the domain

This entitlement fragment names a synthetic domain for the applinks service. It belongs in an appropriately configured and signed Xcode target, not in an arbitrary Swift file. The example domain is illustrative and is not a production service. Verify the entitlement in the actual signed artifact and follow the platform guidance for each supported domain and subdomain.

xml Illustrative associated domains entitlement
<?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>com.apple.developer.associated-domains</key>
  <array><string>applinks:workshop.example</string></array>
</dict>
</plist>
Expected output
The example declares applinks:workshop.example.

The entitlement declares one synthetic applinks domain.

Provide the site association

The website serves an apple-app-site-association file at the documented location without a filename extension. This example uses a synthetic application identifier and a limited article path; it does not establish a real association. Replace the example only in a domain and signed app you control, following the current Apple documentation and checking the actual application identifier and URL policy.

json Synthetic association file
{
  "applinks": {
    "details": [
      {
        "appIDs": ["ABCDE12345.com.example.workshop"],
        "components": [{ "/": "/articles/*" }]
      }
    ]
  }
}
Expected output
The synthetic file does not associate a real application.

The file illustrates an app identifier and an article path pattern using nonproduction values.

Validate and authorize separately

A delivered Universal Link remains external input. Parse the URL, accept only intended hosts and paths, validate parameters and handle missing records. Retrieve protected data through an authenticated server operation that authorizes the specific user and object. Test a malformed URL and another account’s record with synthetic data; a verified domain is not an access-control decision.

Verify the signed target

Use an isolated test domain and a correctly signed test app, then follow Apple’s current diagnostic guidance for association delivery and link handling. Test matching and nonmatching paths, fresh installation or other documented verification scenarios, and browser fallback. Record the device, OS and build identity without exposing signing keys. A valid JSON file or entitlement declaration alone does not prove device association.

Common errors and fixes

A matching link stays in the browser.

Why it happens
The entitlement, site association or signed app identity does not match, among other possible causes.
How to fix it
Inspect the signed artifact and domain association with official diagnostics.
Prevent it next time
Test the actual signed build and controlled domain.

An unexpected URL reaches an unsafe route.

Why it happens
The handler trusts the incoming URL without validating its path or parameters.
How to fix it
Parse and restrict supported destinations.
Prevent it next time
Test malformed and nonmatching links.

A linked record belonging to another account is displayed.

Why it happens
Domain association was mistaken for object authorization.
How to fix it
Authorize the requested record at the server.
Prevent it next time
Test direct requests using separate synthetic accounts.

2 practice exercises

1. Does a correct entitlement alone prove a Universal Link association?

Show worked solution

No. The site association, signed app identity, platform delivery and link handling also matter. Verify the actual signed target and controlled domain.

2. Why must the application still validate an associated URL?

Show worked solution

The URL is external input and may contain unsupported or malicious values. Validate its path and parameters, then authorize any protected record separately.

Key takeaways

  • Associated domains connect an app and website.
  • Treat every incoming URL as external input.
  • Verify target behavior and server authorization independently.

Official references