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

执行ionic cap build ios遇NSLocationWhenInUseUsageDescription错误求助

问题解决:ionic cap build ios 解析info.plist报错

错误根源

你的info.plist存在XML结构错误:UIViewControllerBasedStatusBarAppearance这个key未配置对应的值,后续直接跳转至下一个keyNSLocationWhenInUseUsageDescription,而原本属于前者的<true/>被错误放置在位置权限描述之后,导致plist解析器无法识别非法结构,从而抛出Unexpected key "NSLocationWhenInUseUsageDescription" while parsing <dict/>错误。

修复后的完整info.plist代码

将<true/>移至UIViewControllerBasedStatusBarAppearance的key后方,修正后的代码如下:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CFBundleDevelopmentRegion</key>
    <string>en</string>
    <key>CFBundleDisplayName</key>
        <string>Mascota Anuncios</string>
    <key>CFBundleExecutable</key>
    <string>$(EXECUTABLE_NAME)</string>
    <key>CFBundleIdentifier</key>
    <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>$(PRODUCT_NAME)</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>1.0</string>
    <key>CFBundleVersion</key>
    <string>1</string>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>UILaunchStoryboardName</key>
    <string>LaunchScreen</string>
    <key>UIMainStoryboardFile</key>
    <string>Main</string>
    <key>UIRequiredDeviceCapabilities</key>
    <array>
        <string>armv7</string>
    </array>
    <key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    <key>UISupportedInterfaceOrientations~ipad</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationPortraitUpsideDown</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    <key>UIViewControllerBasedStatusBarAppearance</key>
    <true/>
    <key>NSLocationWhenInUseUsageDescription</key>
    <string>Necesitamos acceder a la ubicacion para obtener una info precisa de su ubicacion actual</string>
</dict>
</plist>

后续步骤

  1. 替换项目中原有的info.plist文件内容
  2. 重新执行ionic cap build ios命令,此时解析错误会消失,Xcode也能正常打开并显示plist文件

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.10 17:20:27