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

升级Xcode15后MAUI iOS Debug构建失败,关联Microsoft.Data.Sqlite

问题:Xcode 15升级后MAUI iOS Debug构建clang链接报错(依赖Microsoft.Data.Sqlite)

环境背景

  • Mac升级至Xcode 15(此前版本为Xcode 14.2)
  • 开发已久的.NET 7 MAUI iOS应用,Debug版本构建失败

报错信息

clang exited with code1:
ld: warning: ignoring duplicate libraries: '-lSystem.IO.Compression.Native', '-lSystem.Native', '-lSystem.Net.Security.Native', '-lSystem.Security.Cryptography.Native.Apple', '-lcompression', '-lmono-component-debugger', '-lmono-component-diagnostics_tracing', '-lmono-component-hot_reload', '-lmonosgen-2.0', '-lxamarin-dotnet-debug'
ld: building for 'iOS-simulator', but linking in object file (/Users/user/Library/Caches/Xamarin/mtbs/builds/Project/8618b5190f6d6128dea985b3e984c867243d6f87f73c5927fc8c844f1e1e1b50/obj/Debug/net7.0-ios/iossimulator-arm64/linker-cache/e_sqlite3.a[arm64][2](sqlite3.o)) built for 'iOS'
1>clang: error: linker command failed with exit code 1 (use -v to see invocation)

已做排查

  • 问题触发点:应用依赖的DevExpress XPO库引用了Microsoft.Data.Sqlite,安装该库后必现报错
  • 测试覆盖:Microsoft.Data.Sqlite 7.0.0至7.0.11多个版本(含7.0.7、7.0.8),新建空白项目添加库后仍复现问题
  • 模拟器版本切换:从iOS 17.0改为16.2,问题未解决

解决方案

方法1:指定SQLite原生库的平台适配

在项目的.csproj文件中添加以下配置,强制为iOS模拟器匹配对应架构的原生库:

<ItemGroup Condition="$(TargetFramework.Contains('-ios')) and $(Configuration) == 'Debug'">
  <NativeReference Include="$(NuGetPackageRoot)microsoft.data.sqlite.core\7.0.11\runtimes\ios-arm64\native\e_sqlite3.a" Condition="$(RuntimeIdentifier) == 'ios-arm64'" />
  <NativeReference Include="$(NuGetPackageRoot)microsoft.data.sqlite.core\7.0.11\runtimes\iossimulator-arm64\native\e_sqlite3.a" Condition="$(RuntimeIdentifier) == 'iossimulator-arm64'" />
  <NativeReference Include="$(NuGetPackageRoot)microsoft.data.sqlite.core\7.0.11\runtimes\iossimulator-x64\native\e_sqlite3.a" Condition="$(RuntimeIdentifier) == 'iossimulator-x64'" />
</ItemGroup>

注意将配置中的版本号替换为你实际使用的Microsoft.Data.Sqlite.Core版本。

方法2:更新MAUI适配包至兼容Xcode 15的版本

将项目中所有Microsoft.Maui.*相关NuGet包更新至.NET 7的最新补丁版本(至少7.0.100及以上),该版本已修复Xcode 15的链接兼容性问题。

方法3:清理缓存后重新构建

  1. 删除以下目录的缓存文件:
    • ~/Library/Caches/Xamarin/mtbs
    • 项目根目录下的obj和bin文件夹
  2. 执行dotnet clean命令,再重新构建项目

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.10 19:25:03