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
相关产品推荐
相关产品推荐

