info.plist配置Deep-link后Safari无响应,提示无法找到服务器求助
Hey there, let's troubleshoot this deep link issue step by step. The error you're seeing ("Safari cannot open the page because the server cannot be found") is a big clue here—let's break down what's going wrong and how to fix it:
The scheme you're using (myapp.com) includes a dot, which makes Safari interpret it as a web domain instead of an app deep link. When you try to open it, Safari attempts to send an HTTP request to myapp.com (which doesn’t exist as a public server), hence the error.
Fix: Switch to a simple, dot-free scheme like myapp. Update your Info.plist to this:
<key>CFBundleURLTypes</key> <array> <dict> <key>CFBundleURLName</key> <string>com.myapp.customer</string> <key>CFBundleURLSchemes</key> <array> <string>myapp</string> </array> </dict> </array>
If you’re just typing myapp.com into Safari’s address bar, Safari automatically prepends http:// to it, turning it into a web request instead of a deep link.
Proper Testing Methods:
- Create a simple HTML file with a link:
<a href="myapp://">Open My App</a>, open this file in Safari, and tap the link. - Type the full deep link directly into Safari’s address bar:
myapp://(don’t forget the://suffix). - Use the Notes app: Type
myapp://, long-press it, and select "Open in [Your App Name]". - For simulator testing, run this terminal command:
xcrun simctl openurl booted myapp://
- Make sure you’ve rebuilt and reinstalled your app after updating the
Info.plist—changes won’t take effect until you do this. - Double-check that the
CFBundleURLTypesconfiguration is applied to your main app target (not a test or extension target). - For iOS 13+, confirm you haven’t disabled deep links for your app in Settings > [Your App] > Safari > Allow Website Access (it should be set to "Allow" or "Ask").
While this isn’t required for Safari to open your app, if you plan to launch your app from another iOS app (not just Safari), add your scheme to LSApplicationQueriesSchemes in Info.plist to avoid runtime errors:
<key>LSApplicationQueriesSchemes</key> <array> <string>myapp</string> </array>
内容的提问来源于stack exchange,提问作者Mehrdad




