.net 应用在编译时可能需要指定版本的 xcode, 而且往往不支持最新的 xcode 版本, 这时可以从苹果官网下载不同版本的 xcode 的 xip 文件, 解压缩至到 Xcode.app (可重命名加上版本号), 复制到 /Applications 中,并通过 xcode-select 指定版本。
可以使用三方工具 xcodes 或是手工下载、安装、配置。 操作如下
# 最方便使用三方工具, 在工具中登录 apple 账号, 下载不同版本的 xcode , 然后选择指定版本的 xcode , 点击激活
brew install --cask xcodes
# 下载 xcode xip 文件
https://developer.apple.com/xcode/resources/
# 解压缩并重命名
xip -x Xcode_15.2.xip
mv Xcode.app /Applications/Xcode_15.2.app
# 切换不同的 xcode
sudo xcode-select -s /Applications/Xcode_15.2.app/Contents/Developer
# 查看当前的 xxcode 版本
xcode-select -p
# 验证当前版本
xcodebuild -version
然后在项目中使用 <TargetFramework>net10.0-macos26.2</TargetFramework> 指定编译的 xcode 版本。如果不指定 xcode 版本号, 可能三方库使用不同版本,导致编译失败。
# ai 建议使用如下配置, 或是 net10.0-macos26.0,但多版本一起编译时必遇到版本兼容问题
<TargetFramework>net10.0-macos</TargetFramework>
<TargetPlatformVersion>26.0</TargetPlatformVersion> # 指定编译平台版本
<SupportedOSPlatformVersion>15.0</SupportedOSPlatformVersion> # 指定最低支持的系统版本
在 https://github.com/dotnet/macios 查看当前最新支持的 xcode 版本信息
在 https://github.com/dotnet/android 查看当前最新支持的 android 版本信息
在 https://github.com/dotnet/maui/wiki/Release-Versions 查看 maui 版本信息