iOSのUniversal Linksを設定していたが、シミュレータでは正しく挙動するものの実機では一切動かないということが起こった。
- apple-site-association には、
[Team ID].[Bundle ID]
の形式でapplinksを記載していた - App Search API Validation Tool では
Error no apps with domain entitlements
と出ていたが、これは関係がないという記事が多く見られた。 - branch のバリデータ では正しく設定されていると出ていた
アプリ側でちゃんとEntitlementsの値がセットされているかを確認するために、codesignコマンドでEntitlementsを確認してみると…
$ codesign -d --entitlements :- MyApp.app
<?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>application-identifier</key> <string>BBBBBBBBBB.net.iseteki.myapp</string> <key>aps-environment</key> <string>development</string> <key>com.apple.developer.applesignin</key> <array> <string>Default</string> </array> <key>com.apple.developer.associated-domains</key> <array> <string>applinks:myapp.example.com</string> <string>activitycontinuation:myapp.example.com</string> </array> <key>com.apple.developer.team-identifier</key> <string>AAAAAAAAAA</string> <key>get-task-allow</key> <true/> </dict> </plist>
…おわかりいただけたであろうか?
application-identifierのprefixとteam-identifierが一致してない!
昔から作られているアプリはApp ID Prefixが異なる場合がある
昔、iOS Dev CenterでApp IDを作る際にApp ID Prefixを新規に生成することができた。現在はTeam ID固定となっていてこの設定をすることはできないようになっているが、昔から存在するApp IDの場合はこのBundle ID Prefixの指定が残っている。
App IDに指定されているApp ID PrefixはApp IDの設定画面で確認できる。
App ID Prefixの末に (Team ID) と書かれていない場合は、Team IDとは異なるApp ID Prefixになっている。
apple-site-association に指定するBundle IdentifierのPrefixをここに表示されているApp ID Prefixに修正することで問題なく動作するようになった。