.NET Maui添加Entitlements.plist会导致构建失败

huangapple go评论78阅读模式
英文:

.NET Maui adding Entitlements.plist breaks build

问题

使用 Visual Studio CE 2022 17.44

遵循设置 iOS 上的 appLinks 的说明,其中的一步是添加以下内容到 Entitlements.plist:

<?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:popupshop.azurewebsites.net</string>
            <string>applinks:*.popupshop.azurewebsites.net</string>
        </array>
    </dict>
</plist>

然后,将 Entitlements.plist 添加为自定义资源规则文件:

这将在项目文件中添加以下行:

<CodesignResourceRules>Platforms\iOS\Entitlements.plist</CodesignResourceRules>

一旦添加了这个,项目将不再构建。如果将其删除或替换为:

<CodesignEntitlements>Platforms\iOS\Entitlements.plist</CodesignEntitlements>

根据某人的建议,项目将再次构建,但访问 applink 时不会切换到应用程序。https://popupshop.azurewebsites.net/findshop

我在 https://popupshop.azurewebsites.net/apple-app-site-associationhttps://popupshop.azurewebsites.net/.well-known/apple-app-site-association 中都有 apple-app-site-association 文件,它包含以下内容:

{
    "applinks": {
        "apps": [],
        "details": [
            {
                "appID": "75Q8SL8Q65.net.popupmobile.popupshop",
                "paths": ["/findshop/*"]
            }
        ]
    }
}

不清楚为什么由 Visual Studio 输入的标记会导致构建失败。
更新:
错误如下:

Severity	Code	Description	Project	File	Line	Suppression State
Error		Failed to codesign '/Users/user/Library/Caches/Xamarin/mtbs/builds/PopUpShop.Mobile.Maui/35dcaca089e6ce3e7267432b2824427bbb34327e5d2422b0725e05c26c8d46db/bin/Debug/net7.0-ios/ios-arm64/device-builds/iphone15.3-16.1.2/PopUpShop.Mobile.Maui.app':
Warning: --resource-rules has been deprecated in Mac OS X >= 10.10!
bin/Debug/net7.0-ios/ios-arm64/device-builds/iphone15.3-16.1.2/PopUpShop.Mobile.Maui.app/ResourceRules.plist: cannot read resources
PopUpShop.Mobile.Maui	C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk.1.1477\tools\msbuild\iOS\Xamarin.Shared.targets	2128

更新:上面的 Visual Studio 截图与我在 Microsoft 网站上看到的不同(参见下文)。出于某种原因,我缺少"自定义权限"部分。
截图链接

英文:

Using Visual Studio CE 2022 17.44

Following the directions for setting up appLinks on iOS, one of the steps is to add the Entitlements.plist with the following:

&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;!DOCTYPE plist PUBLIC &quot;-//Apple//DTD PLIST 1.0//EN&quot; &quot;http://www.apple.com/DTDs/PropertyList-1.0.dtd&quot;&gt;
&lt;plist version=&quot;1.0&quot;&gt;
    &lt;dict&gt;
        &lt;key&gt;com.apple.developer.associated-domains&lt;/key&gt;
        &lt;array&gt;
	        &lt;string&gt;applinks:popupshop.azurewebsites.net&lt;/string&gt;
    		&lt;string&gt;applinks:*.popupshop.azurewebsites.net&lt;/string&gt;
        &lt;/array&gt;
    &lt;/dict&gt;
&lt;/plist&gt;

I then add the Entitlements.plist as the custom resource rules file:

.NET Maui添加Entitlements.plist会导致构建失败

This adds this line to the project file:

&lt;CodesignResourceRules&gt;Platforms\iOS\Entitlements.plist&lt;/CodesignResourceRules&gt;

Once this has been added the project no longer builds. If I remove it or replace it with:

&lt;CodesignEntitlements&gt;Platforms\iOS\Entitlements.plist&lt;/CodesignEntitlements&gt;

as per someone's suggestion, the project will build again, but accessing the applink does not switch over to the app. https://popupshop.azurewebsites.net/findshop

I have the apple-app-site-association file available at https://popupshop.azurewebsites.net/apple-app-site-association and https://popupshop.azurewebsites.net/.well-known/apple-app-site-association

which contains:

{
    applinks: {
        apps: [ ],
        details: [
            {
                appID: &quot;75Q8SL8Q65.net.popupmobile.popupshop&quot;,
                paths: [ &quot;/findshop/*&quot; ]
            }
        ] 
    }
}

Not sure why the tag entered by Visual Studio blows up the build.
UPDATE:
the error is the following:

Severity	Code	Description	Project	File	Line	Suppression State
Error		Failed to codesign &#39;/Users/user/Library/Caches/Xamarin/mtbs/builds/PopUpShop.Mobile.Maui/35dcaca089e6ce3e7267432b2824427bbb34327e5d2422b0725e05c26c8d46db/bin/Debug/net7.0-ios/ios-arm64/device-builds/iphone15.3-16.1.2/PopUpShop.Mobile.Maui.app&#39;: 
Warning: --resource-rules has been deprecated in Mac OS X &gt;= 10.10!



bin/Debug/net7.0-ios/ios-arm64/device-builds/iphone15.3-16.1.2/PopUpShop.Mobile.Maui.app/ResourceRules.plist: cannot read resources

    	PopUpShop.Mobile.Maui	C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk.1.1477\tools\msbuild\iOS\Xamarin.Shared.targets	2128	

UPDATE: The VS Screen shot above is different than what i see on the Microsoft site (see below). I am missing the 'Custom Entitlements' section for some reason.

.NET Maui添加Entitlements.plist会导致构建失败

答案1

得分: 1

不确定为什么我的Visual Studio出了问题,但如果您的情况也一样,想要添加Entitlements.plist,请在iOS调试和发布部分的project.csproj中添加以下内容:

&lt;PropertyGroup Condition=&quot;&#39;$(Configuration)|$(TargetFramework)|$(Platform)&#39;==&#39;Debug|net7.0-ios|AnyCPU&#39;&quot;&gt;
....
&lt;CodesignEntitlements&gt;Platforms\iOS\Entitlements.plist&lt;/CodesignEntitlements&gt;
&lt;/PropertyGroup&gt;
英文:

Not sure why my visual studio is broken, but if yours is the same and you want to add Entitlements.plist, add the following to your project.csproj under the ios debug and release sections:

&lt;PropertyGroup Condition=&quot;&#39;$(Configuration)|$(TargetFramework)|$(Platform)&#39;==&#39;Debug|net7.0-ios|AnyCPU&#39;&quot;&gt;
....
  &lt;CodesignEntitlements&gt;Platforms\iOS\Entitlements.plist&lt;/CodesignEntitlements&gt;
&lt;/PropertyGroup&gt;

huangapple
  • 本文由 发表于 2023年3月7日 12:21:58
  • 转载请务必保留本文链接:https://go.coder-hub.com/75658021.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定