An iPhone opens a universal link in your app only when three things agree: the app's Associated Domains entitlement, the apple-app-site-association file on your domain, and the way the link was opened. When one of them is off, iOS opens the web page instead and says nothing. Here are the causes in the order they usually turn up.
The symptom
You tap an https link to your own domain, the app is installed, and Safari opens the page. Apple describes it plainly: a universal link opens in the app when the app is installed, and otherwise in the default web browser (TN3155). There is no error to read, so check each cause below in turn.
The link was typed in, or opened from your own site or app
- Typing the URL into the browser's address bar never opens the app: Apple calls it direct navigation within the web browser (TN3155).
- A link on the same domain as the page you are already on continues in the browser, even when its path matches. Apple's fix is a different subdomain for links that should open the app, with its own entry in the entitlement and its own file (TN3155).
- Your own app opening the link with
open(_:options:completionHandler:), or SwiftUI'sopenURL, does not open it in your app (Allowing apps and websites to link to your content). - Safari supports universal links fully; other browsers decide for themselves whether to support them (TN3155).
- A link that redirects to your universal link, tapped in another app, still reaches your app, through the browser (TN3155).
- Test from another app instead. Apple's own test is to paste the link into Notes and long-press it (TN3155).
Someone chose to open it in Safari
Long-press the link: if both "open in the app" and "open in the browser" are offered, the set-up works. The option chosen there becomes the device's default for links from that domain; to change it back, long-press again and choose the app (TN3155).
The entitlement does not name the domain
- In Xcode, Signing & Capabilities, the Associated Domains capability must list
applinks:followed by the fully qualified domain: no path, no query and no trailing slash (Supporting associated domains), apart from Apple's own?mode=developerbelow, and no port (TN3155). - Each subdomain is its own domain. A file at
https://example.com/.well-known/apple-app-site-associationservesapplinks:example.comand the wildcardapplinks:*.example.com, but notapplinks:www.example.com, which needs its own file atwww.example.com(TN3155). - The apps listed in the file must match the app carrying the entitlement (Supporting associated domains).
applinks:example.com
applinks:www.example.com
The file is not where Apple looks, or it redirects
The file has no extension and lives at one address, served over https with a valid certificate and no redirects (Supporting associated domains):
https://<fully qualified domain>/.well-known/apple-app-site-association
Apple's technote gives the commands to see what your server really returns (TN3155):
curl -v https://example.com/.well-known/apple-app-site-association
curl -A "MyAgent-Bot/*" https://example.com/.well-known/apple-app-site-association
- A 301 or 302 means a redirect, which is not supported for this file.
- A 403 or 404 means the file is not reachable. It must be open to every IP address, in every location, and to any user agent: the second command checks the last of those.
Both link files side by side, with Google's tools for the Android one: checking apple-app-site-association and assetlinks.json.
The file does not claim the app or the path
The applinks section lists app identifiers as <Application Identifier Prefix>.<Bundle Identifier> in appIDs, and the paths to open in components (Supporting associated domains):
{
"applinks": {
"details": [
{
"appIDs": ["ABCDE12345.com.example.app"],
"components": [
{ "/": "/buy/*", "comment": "Matches any URL with a path that starts with /buy/." }
]
}
]
}
}
- Do not mix the current format (
appIDsandcomponents) with the older one (appIDandpaths) in one file (TN3155). - On a Mac,
swcutil dlchecks that the file can be downloaded, andswcutil verifychecks a saved copy of it (-j) against the domain and a URL (TN3155):
sudo swcutil dl -d example.com
sudo swcutil verify -d example.com -j ./example.json -u https://example.com/buy/42
Apple's CDN still has the old file
- Since iOS 14 and macOS 11, devices do not ask your server for the file: they ask an Apple-managed content delivery network (Supporting associated domains).
- The CDN requests your file within 24 hours, and devices check for updates about once a week after the app is installed (Supporting associated domains). To get a newer version onto a device, reinstall the app; Apple offers no direct way to invalidate the CDN's copy (TN3155).
- While you develop,
applinks:example.com?mode=developermakes a build signed with a development profile fetch the file from your server instead of the CDN, on a device where developer mode is turned on (Associated Domains Entitlement). On that iPhone, Settings, Developer, Universal Links: turn on Associated Domains Development, then Diagnostics tells you whether a URL is valid for an installed app (TN3155). - A sysdiagnose from the device has the record: in
swcutil_show.txt,Site/Fmwk Approvalsays whether Apple's CDN approved your links and matched the pattern,User Approvalholds the long-press choice, andLast Check/Next Checkwhen the CDN last asked your site for the file and when it will again (TN3155).
Test it in Diver
- In the browser build at https://app.usediver.com, add the app and an environment with its link domain, Apple team ID and iOS bundle ID. Diver generates the
apple-app-site-associationfor that environment from those fields, one path pattern per deep link template; the admin console shows the file to copy or download, with its hosting requirements. Diver does not host it: your domain serves it, pasted in, or proxied from Diver with an API key so it stays in step with the environment (link files). - Build the https form of a deep link (the environment's link domain, then the path) and send it to an iPhone signed in to your account. Diver answers
Delivered to iPhone - waiting to be opened., and the link opens when you tap it there, from an app rather than from Safari's address bar. Receiving needs the phone app on that iPhone, which is coming soon. - In the desktop or phone app (coming soon), press Check on the environment. Diver fetches the file from your link domain itself and answers per file:
Served and claims this app.,Redirected - Apple will not follow one for this file.,Nothing is served here.,Served, but not valid JSON.,Served, but it does not claim this app.orCould not reach the domain.A browser cannot run this check: the file is served for Apple, not for a web page.
Diver's check compares the team ID and bundle ID the file claims, not the components patterns, so keep swcutil verify for the paths. And it reads your domain directly, not Apple's CDN: when Diver says the file is fine and the iPhone still opens Safari, look at the CDN's copy and the entitlement.
The phone and desktop apps are coming soon: tell me when they ship.