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

Info.plist含CFBundleVersion但Xcode仍提示无效问题求助

问题:Info.plist已包含CFBundleVersion仍提示无效

开发项目时,为获取经纬度添加了Info.plist,基于同一代码库操作后,收到错误提示:

The application's Info.plist does not contain a valid CFBundleVersion. Ensure your bundle contains a valid CFBundleVersion

尽管Info.plist里已经有CFBundleVersion字段且值为1,Xcode还是持续报错,试过Stack Overflow上的相关方案都没用,附上我的Info.plist代码:

<?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>CFBundleVersion</key>
    <string>1</string>
    <key>CFBundleDisplayName</key>
    <string>Example</string>
    <key>CFBundleIdentifier</key>
    <string>com.********</string>
    <key>CFBundleShortVersionString</key>
    <string>1</string>
    <key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
        <string>Hello, Application wants to use your location</string>
    <key>NSLocationAlwaysUsageDescription</key>
        <string>Hello, Application wants to use your location</string>
    <key>NSLocationWhenInUseUsageDescription</key>
        <string>Hello, Application wants to use your location</string>
</dict>
</plist>
解决思路
  • 检查Xcode项目配置覆盖情况:打开项目Target -> Build Settings,搜索Versioning,确认Current Project Version和Marketing Version分别与Info.plist中的CFBundleVersion、CFBundleShortVersionString一致,Xcode可能会用配置值覆盖plist内容。
  • 验证Info.plist的Target关联:选中Info.plist文件,查看右侧File Inspector,确认Target Membership勾选了当前应用Target,未关联会导致Xcode无法读取正确的plist文件。
  • 清理Xcode缓存:按Cmd+Shift+K清理Build文件夹,再按Cmd+Option+Shift+K清理Derived Data,重启Xcode后重新编译。
  • 检查plist文件语法:使用命令plutil -lint YourInfo.plist(替换为你的plist路径)验证文件格式是否合法,排查隐性的语法错误或不可见字符。
  • 确认plist文件路径正确性:在Target的Build Settings中搜索Info.plist File,检查路径是否指向你编辑的那一个,避免Xcode读取了其他plist文件。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.09 19:48:29