Xamarin iOS模拟器运行时无法自动更新应用求助
Xamarin iOS模拟器无法自动更新应用的排查方案
问题描述
3天前项目在iOS模拟器上运行正常,点击启动按钮会自动关闭旧版本并安装启动新版本。当前点击启动按钮后进程卡在启动阶段,必须手动关闭应用才会开始安装新版本。
运行环境:
- VS2022 Enterprise
- Mac 2018(Ventura系统)
- Xcode 14.3.1
- iPhone 14 Pro iOS 16.4模拟器
启动卡住时的日志
========== Build: 1 succeeded, 0 failed, 1 up-to-date, 7 skipped ========== ========== Build started at 1:27 AM and took 25.478 seconds ========== ========== Deploy: 0 succeeded, 0 failed, 0 skipped ========== ========== Deploy started at 1:27 AM and took 25.478 seconds ========== Launching 'MyApp.iOS' on 'iPhone 14 Pro iOS 16.4'...
手动关闭应用后的日志
Xamarin.Hosting: Simulated process has exited (could not get process info: Can't find process with ID 9748). Starting Simulator to launch App... Launching... The Simulator has been started to launch App... Launch succeeded. The app 'MaxGo.iOS' has been successfully launched on 'iPhone 14 Pro iOS 16.4'. Using Xcode 14.3.1 found in /Applications/Xcode 14.app/Contents/Developer Xamarin.Hosting: Xcode Version: 14.3.1 Xamarin.Hosting: Verbosity: 1 Xamarin.Hosting: Xamarin.Hosting Xamarin.Hosting: Xcode: /Applications/Xcode 14.app Xamarin.Hosting: Version: 5873b04b5d (refs/heads/main) Xamarin.Hosting: Simulator watchdogs are already disabled for 'iOS 16.4 (20E247) - iPhone 14 Pro'. Xamarin.Hosting: Installing on iOS 16.4 (20E247) - iPhone 14 Pro by executing 'xcrun simctl install 4085A322-A16F-443C-992F-0C51F2E86BB8 /Users/yohanesai/Library/Caches/Xamarin/mtbs/builds/MaxGo.iOS/a17f6534d68e8b92f1cc5319a6aed7589eecdf4b78edea37d73c0de0d639f43d/bin/iPhoneSimulator/Ad-Hoc/MaxGoiOS.app' Xamarin.Hosting: No need to boot (already booted): iPhone 14 Pro Xamarin.Hosting: Launching on iOS 16.4 (20E247) - iPhone 14 Pro by executing 'xcrun simctl launch --console --terminate-running-process 4085A322-A16F-443C-992F-0C51F2E86BB8 com.app.MyApp -connection-mode none' with environment: Xamarin.Hosting: Can't process potentially bad load commands, because the app is signed. xcrun simctl launch --console --terminate-running-process 4085A322-A16F-443C-992F-0C51F2E86BB8 com.app.MyApp-connection-mode none DEVELOPER_DIR=/Applications/Xcode 14.app Xamarin.Hosting: The bundle id com.app.MyAPp was successfully installed. SIMCTL_CHILD_OS_ACTIVITY_DT_MODE=YES SIMCTL_CHILD_NSUnbufferedIO=YES NSUnbufferedIO=YES com.app.MyApp: 10325
排查与解决步骤
重置iOS模拟器
- 打开iOS模拟器,点击顶部菜单
Simulator > Reset Content and Settings...,确认重置操作 - 重启模拟器后重新部署应用
- 打开iOS模拟器,点击顶部菜单
清理Xamarin构建缓存
- 删除Mac上的Xamarin缓存目录:
~/Library/Caches/Xamarin/mtbs - 在VS2022中执行
Clean Solution,再依次执行Build和Deploy
- 删除Mac上的Xamarin缓存目录:
修正应用签名配置
日志中出现Can't process potentially bad load commands, because the app is signed,且当前使用Ad-Hoc配置部署模拟器,这可能是问题诱因:- 打开iOS项目属性,进入
iOS Bundle Signing页面 - 将
Configuration切换为Debug,Signing Identity选择iOS Developer或启用自动签名 - 确保模拟器部署使用Debug配置,而非Ad-Hoc
- 打开iOS项目属性,进入
检查Xcode与Xamarin兼容性
- 在VS2022的Xamarin设置中查看版本匹配信息,确认当前Xamarin版本支持Xcode 14.3.1
- 若存在版本不匹配,升级Xamarin或降级Xcode至官方兼容版本
强制终止模拟器进程
- 在Mac的
活动监视器中找到iOS Simulator进程,强制退出 - 返回VS2022点击启动按钮,观察是否能自动更新应用
- 在Mac的
内容的提问来源于stack exchange,提问作者Yohanes AI
相关产品推荐
相关产品推荐

