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

无法在iOS 15模拟器运行iOS应用,请求技术支持

问题描述
  • 无iPhone 13实体设备,需在iOS 15.4模拟器调试应用
  • 应用在iPhone 6上运行正常,但在iPhone 13模拟器上界面超出屏幕范围,存在分辨率适配问题
  • 模拟器启动应用时立即崩溃,错误提示截图如下:
    错误提示
  • 已在info.plist中配置相机权限(应用仅需网络和相机权限),怀疑是权限问题但不确定

更新:模拟器日志

Startup:
    arguments: --device=27495837-1C30-49ED-B814-DC14E7112DB8 --launchsim=//Users/prescottchartier/Library/Caches/Xamarin/mtbs/builds/iOSPhotoManager/d4a378afae087127b50d68ae980e92c7568732fc756e3455147359d52176d94a/bin/iPhoneSimulator/Debug/iOSPhotoManager.app -argument=-monodevelop-port -argument=53149 -setenv=__XAMARIN_DEBUG_PORT__=53149 --sdkroot=/Applications/Xcode.app -h=192.168.1.8 -ssh=prescottchartier 
    version: 17.3.0.471 (97213889733ed3f399d3574c2f4f20e614e9dc7a)
Connection state changed:
    State: Connecting
SSH Connect:
    target: 192.168.1.8
Using SSH pass phrase
SSH connected
Connection state changed:
    State: SshConnected
Connection state changed:
    State: CheckingServer
Connection state changed:
    State: SettingUpServer
Starting server
[Server] ready:50593
Connection state changed:
    State: Connecting
Connection state changed:
    State: CheckingServer
Connection state changed:
    State: Connected
Start device request:
    Current State: Unknown
    UUID: 27495837-1C30-49ED-B814-DC14E7112DB8
    Name: iPhone 13
    Platform: iOS
    Version: 15.5
Device state changed:
    UUID: 27495837-1C30-49ED-B814-DC14E7112DB8
    State: Starting
Device state changed:
    UUID: 27495837-1C30-49ED-B814-DC14E7112DB8
    State: Started
SizeForScreen:
    Monitor: 0,0,1366,728
    Scale: 1,1
    Source: 1170,2532
    extraHeight: 84
Warning: App failed to install+launch
System.Exception: Could not launch the app 'com.CGAssociates.PhotoManager' on the device 'iOS 15.5 (19F70) - iPhone 13': simctl returned exit code 3
   at Xamarin.Simulator.Core.Protocol.SimulatorClient.<InstallAndLaunchRemoteAppAsync>d__26.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Xamarin.Simulator.Windows.App.<HandleApp>d__19.MoveNext()
    ErrorCode: 0

    Device: 27495837-1C30-49ED-B814-DC14E7112DB8
    Path: //Users/prescottchartier/Library/Caches/Xamarin/mtbs/builds/iOSPhotoManager/d4a378afae087127b50d68ae980e92c7568732fc756e3455147359d52176d94a/bin/iPhoneSimulator/Debug/iOSPhotoManager.app
    Arguments: -argument=-monodevelop-port -argument=53149 -setenv=__XAMARIN_DEBUG_PORT__=53149 
Connection state changed:
    State: Disconnected
Connection state changed:
    State: Connecting
SSH Connect:
    target: 192.168.1.8
Using SSH pass phrase
SSH connected
Connection state changed:
    State: SshConnected
Connection state changed:
    State: CheckingServer
Connection state changed:
    State: SettingUpServer
Starting server
[Server] ready:50634
Connection state changed:
    State: Connecting
Connection state changed:
    State: CheckingServer
Connection state changed:
    State: Connected
Device state changed:
    UUID: 27495837-1C30-49ED-B814-DC14E7112DB8
    State: Starting
Device state changed:
    UUID: 27495837-1C30-49ED-B814-DC14E7112DB8
    State: Started
解决建议

一、先修复模拟器启动崩溃问题(simctl exit code 3)

这个错误通常关联应用安装失败、模拟器状态异常或Xamarin配置问题,按以下步骤排查:

  1. 清理缓存并重置模拟器
    • 打开Xcode,进入Window > Devices and Simulators,选中iPhone 13模拟器,右键选择Erase All Content and Settings,重置后重启模拟器
    • 删除路径//Users/prescottchartier/Library/Caches/Xamarin/mtbs/builds/iOSPhotoManager/下的所有构建缓存文件,重新构建项目
  2. 检查签名与info.plist配置
    • 确认项目iOS Bundle Signing的Debug模式使用自动签名或有效开发证书
    • 核对info.plist中相机权限配置:确保NSCameraUsageDescriptionkey存在,且对应的值不为空(不能为空字符串)
  3. 同步工具版本
    • 当前Xamarin版本为17.3.0.471,建议更新至最新稳定版;同时确保Xcode版本≥13.4(iOS 15.5模拟器的最低兼容Xcode版本)
  4. 手动用simctl调试
    • 打开终端执行以下命令,手动安装并启动应用,获取更详细的错误输出:
      xcrun simctl install 27495837-1C30-49ED-B814-DC14E7112DB8 //Users/prescottchartier/Library/Caches/Xamarin/mtbs/builds/iOSPhotoManager/d4a378afae087127b50d68ae980e92c7568732fc756e3455147359d52176d94a/bin/iPhoneSimulator/Debug/iOSPhotoManager.app
      xcrun simctl launch 27495837-1C30-49ED-B814-DC14E7112DB8 com.CGAssociates.PhotoManager
      

二、修复屏幕分辨率适配问题

iPhone 6与iPhone 13的屏幕尺寸、像素密度差异显著,适配问题按以下处理:

  1. 强制使用Auto Layout
    • 排查界面布局,确保所有元素依赖Auto Layout约束,而非硬编码的frame坐标或固定宽高值。优先使用相对约束(如左右边距、居中对齐、比例高度等)
  2. 适配安全区域
    • iPhone 13存在刘海和底部安全区,将根视图的布局参考设置为Safe Area,或在代码中获取UIApplication.shared.keyWindow?.safeAreaInsets调整元素位置,避免内容超出可视范围
  3. 修正启动配置
    • 确认项目使用Launch Screen.storyboard作为启动界面,而非静态启动图。静态启动图可能导致模拟器误识别屏幕尺寸
    • 若坚持使用静态启动图,需添加iPhone 13对应的1170x2532分辨率启动资源
  4. 调整视图控制器适配设置
    • 确保ViewController的Automatically Adjusts Scroll View Insets属性处于开启状态,避免滚动视图被刘海遮挡或超出屏幕边界

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.22 17:27:35