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

迁移Xamarin.iOS至.NET iOS时遇GoogleMaps.bundle资源拷贝错误

解决.NET iOS中Xamarin.Google.iOS.Maps的GoogleMaps.bundle资源复制问题

问题原因

模拟器和iOS设备的资源加载机制存在差异,新版Xamarin.Google.iOS.Maps NuGet包在.NET iOS项目中未自动将GoogleMaps.bundle配置到Copy Bundle Resources,导致设备运行时找不到必需资源。

解决步骤

  • 手动添加GoogleMaps.bundle到项目

    1. 定位NuGet包中的bundle文件:通常路径为项目目录/packages/Xamarin.Google.iOS.Maps.6.0.1.1/lib/net6.0-ios15.4/GoogleMaps.bundle(路径需根据你的.NET版本、包版本调整)
    2. 在Visual Studio中右键.NET iOS项目 → 选择Add → Existing Item
    3. 导航到上述路径,选中GoogleMaps.bundle后点击Add
    4. 在解决方案资源管理器中找到该bundle文件,右键选择Properties
    5. 设置Build Action为BundleResource,Copy to Output Directory设为Copy if newer
  • 验证项目配置(可选)
    打开项目的.csproj文件,确认存在以下配置(若缺失则手动添加,注意路径匹配实际情况):

    <BundleResource Include="..\packages\Xamarin.Google.iOS.Maps.6.0.1.1\lib\net6.0-ios15.4\GoogleMaps.bundle">
      <Link>GoogleMaps.bundle</Link>
    </BundleResource>
    
  • 清理重建项目
    右键项目 → Clean → Rebuild,重新部署到iPhone设备测试即可。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.09 02:34:56