发布MAUI iOS应用遇arm64架构未定义符号错误求助
问题描述
在Windows端使用Visual Studio发布.NET MAUI iOS应用时,模拟器可正常构建,但执行发布操作(右键项目→发布)时出现以下链接错误:
Undefined symbols for architecture arm64: "_SSLCopyALPNProtocols",
referenced from _AppleCryptoNative_SslGetAlpnSelected in
libSystem.Security.Cryptography.Native.Apple.a(pal_ssl.c.o)
"_SSLCopyDistinguishedNames", references from:
_AppleCryptoNative_SslCopyCADistiguishedNames in
libSystem.Security.Cryptography.Native.Apple.a(pal_ssl.c.o)
"_SSLCopyPeerTrust", referenced from
_AppleCryptoNative_SslCopyCertChain in
libSystem.Security.Cryptography.Native.Apple.a(pal_ssl.c.o)
_AppleCryptoNative_SsllsHostnameMatch in
libSystem.Security.Cryptography.Native.Apple.a (pal_ssl.c.o)
"_SSLCreateContext", referenced from
_AppleCryptoNative_SslGetCipherSuite in
libSystem.Security.Cryptography.Native.Apple.a (pal_ssl.c.o)
"_SSLGetNegotiatedProtocolVersion", referenced from
_AppleCryptoNative_SslGetProtocolVersion in libSystem.Se
已尝试调整最低SDK版本并重新执行官方发布步骤,问题仍存在。
解决方案
显式链接Security框架:上述未定义符号均属于Apple的Security框架,需在项目中添加引用。
打开项目的.csproj文件,加入以下配置:<ItemGroup> <NativeReference Include="/usr/lib/libSecurity.tbd"> <Kind>Framework</Kind> <Frameworks>Security</Frameworks> </NativeReference> </ItemGroup>或者在Visual Studio的项目属性→iOS构建→额外框架中,添加
Security。验证版本兼容性:确保.NET MAUI 8.0与Mac构建主机上的Xcode版本兼容,推荐使用Xcode 15.x系列版本。版本不匹配会导致底层框架链接异常。
清理缓存后重建:右键项目选择「清理」,手动删除项目目录下的
bin和obj文件夹,再重新执行发布流程,避免旧缓存文件干扰。检查Mac端SDK配置:确认Mac构建主机上安装的iOS SDK版本,不低于项目设置的最低SDK版本。可通过Xcode的「设置→组件」查看已安装的SDK。
内容的提问来源于stack exchange,提问作者Daniel Andersson

