You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Debug模式下Visual Studio未将配置文件应用于MAUI iOS应用的解决方法

问题描述

将Xamarin Forms应用升级为.NET MAUI应用后,iOS设备部署遇到以下问题:

  • Visual Studio可识别配置文件(下拉菜单显示通配符和特定配置文件,手动选择正确配置无效)
  • 构建输出显示已正确识别签名信息:
Target _DetectSigningIdentity:
    Detected signing identity:
            
      Code Signing Key: "Apple Development: Gerwin de Groot (<some id>)" (<some other id>)
      Provisioning Profile: "Example (Debug)" (<some id>)
      Bundle Id: com.example.test
      App Id: <team id>.com.example.test
  • 部署到iPhone设备时失败,报错:
CopyingFile - Path: /Users/gerwin/Public/Projects/Example/bin/Debug/net6.0-ios/ios-arm64/Example.app/Poppins-MediumItalic.ttf
 CopyingFile - PercentComplete: 99%
 CreatingStagingDirectory - PercentComplete: 5%
 ExtractingPackage - PercentComplete: 15%
 InspectingPackage - PercentComplete: 20%
 PreflightingApplication - PercentComplete: 30%
 VerifyingApplication - PercentComplete: 40%
 ApplicationVerificationFailed: Failed to verify code signature of /var/installd/Library/Caches/com.apple.mobile.installd.staging/temp.0vKSvJ/extracted/Example.app : 0xe8008015 (A valid provisioning profile for this executable was not found.)
error MT1006: Could not install the application '/Users/gerwin/Public/Projects/Example/bin/Debug/net6.0-ios/ios-arm64/Example.app' on the device 'Gerwin's iPhone 11': AMDeviceSecureInstallApplicationBundle returned: 0xe8008015.


Application could not be uploaded to the device.
  • 应用在设备上显示空白图标带云标识,点击弹出提示:

Unable To Install "Example"
This app cannot be installed because its integrity could not be verified.

  • 命令行执行Debug模式构建运行同样失败,但Release模式(命令行)可正常运行,Visual Studio因其他bug无法使用Release模式。
解决方案

按顺序尝试以下修复步骤:

1. 清理构建缓存并重新生成

  • 删除项目根目录下的bin和obj文件夹,彻底清除旧构建缓存
  • 执行命令行清理与恢复:
dotnet clean Example.csproj -c Debug -f net6.0-ios
dotnet restore Example.csproj
  • 重新尝试Debug模式构建部署

2. 强制指定csproj中的签名配置

打开项目的.csproj文件,在Debug配置节中明确添加签名参数,避免自动检测冲突:

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net6.0-ios|AnyCPU'">
  <CodesignKey>Apple Development: Gerwin de Groot (&lt;some id&gt;)</CodesignKey>
  <CodesignProvision>Example (Debug)</CodesignProvision>
  <BundleId>com.example.test</BundleId>
</PropertyGroup>
  • 移除任何可能存在的AutomaticSigning相关配置,强制使用指定的证书和配置文件

3. 重置设备证书信任

  • 在iPhone的设置 > 通用 > VPN与设备管理中,找到对应的Apple Development证书
  • 若已信任,先取消信任,重启设备后重新完成信任操作

4. 重新生成并安装配置文件

  • 登录Apple开发者后台,删除现有Debug配置文件,重新生成包含目标设备UDID和对应Bundle ID的配置文件
  • 在Visual Studio中进入工具 > 选项 > Xamarin > Apple账户,刷新账户并重新下载配置文件;或手动双击下载的.mobileprovision文件完成本地安装

5. 验证设备UDID是否在配置文件中

  • 执行命令查看配置文件内容,确认目标设备UDID在授权列表内:
security cms -D -i "~/Library/MobileDevice/Provisioning Profiles/[配置文件UUID].mobileprovision"
  • 检查输出的ProvisionedDevices字段,确认包含目标iPhone的UDID

6. 调整Debug模式签名选项

在项目属性的iOS签名设置中:

  • 关闭「自动管理签名」,手动选择正确的开发团队、证书和配置文件
  • 确保「启用调试」选项已勾选,同时确认「优化代码」和「链接器行为」设置未干扰签名流程

7. 更新SDK与开发工具

  • 检查并更新至最新稳定版.NET MAUI SDK(通过dotnet --list-sdks查看版本)
  • 安装Visual Studio最新更新,确保Xamarin/iOS相关组件为最新状态,修复已知的签名部署bug

内容的提问来源于stack exchange,提问作者Glorfindel

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.05 18:15:35