简体   繁体   English

从.xcconfig 配置关联域

[英]Configure associated domain from .xcconfig

I have an app with multiple schemes, where I want to have a different associated domain for each scheme.我有一个包含多个方案的应用程序,我希望每个方案都有一个不同的关联域。

I have the following .entitlements file:我有以下.entitlements文件:

<?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:$(ASSOCIATED_DOMAIN)</string>
        <string>webcredentials:(ASSOCIATED_DOMAIN)</string>
    </array>
</dict>
</plist>

My .xcconfig files look like this ( ?mode=developer is only there to verify everything is working and will be removed):我的.xcconfig文件如下所示( ?mode=developer仅用于验证一切正常,并将被删除):

// ...
ASSOCIATED_DOMAIN="my.domain.com?mode=developer"

I tried to verify my link with the following command, but this opens mobile Safari:我尝试使用以下命令验证我的链接,但这会打开手机 Safari:

xcrun simctl openurl booted 'https://my.domain.com/app/link'

My /.well-known/apple-app-site-association file is accessible and when I inline my domain and remove the $(ASSOCIATED_DOMAIN) the app link works as expected by opening the app instead of Safari.我的/.well-known/apple-app-site-association文件是可访问的,当我内联我的域并删除$(ASSOCIATED_DOMAIN)时,通过打开应用程序而不是 Safari,应用程序链接按预期工作。 In this case, my .entitlements file looks like this:在这种情况下,我的.entitlements文件如下所示:

<?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:my.domain.com?mode=developer</string>
        <string>webcredentials:my.domain.com?mode=developer</string>
    </array>
</dict>
</plist>

Does anybody have a suggestion what might be wrong?有没有人有什么可能是错的建议? Thanks!谢谢!

Instead of using a variable for the ASSOCIATED_DOMAIN value, consider specifying a separate entitlements file for each of the schemes.不要为 ASSOCIATED_DOMAIN 值使用变量,而是考虑为每个方案指定一个单独的权利文件。 In the relevant xcconfig file, this can be done by setting:在相关的 xcconfig 文件中,这可以通过设置来完成:

CODE_SIGN_ENTITLEMENTS = [location of the file].entitlements

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM