IOS 应用程序在添加时在 info.plist 中缺少目的字符串

Posted

技术标签:

【中文标题】IOS 应用程序在添加时在 info.plist 中缺少目的字符串【英文标题】:IOS app missing purpose string in info.plist while it is added 【发布时间】:2020-01-17 10:35:05 【问题描述】:

我的 ios 应用程序现在被拒绝 3 次,因为缺少 info.plist 中的目的字符串。苹果说我必须为位置使用添加目的字符串。有趣的是,我补充说,它在 info.plist 中,但由于某种原因,手机和 Apple 都没有找到它。我做错了什么?!

这是我的 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>CFBundleDisplayName</key>
    <string>----</string>
    <key>CFBundleShortVersionString</key>
    <string>1.0</string>
    <key>CFBundleVersion</key>
    <string>1.1</string>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>MinimumOSVersion</key>
    <string>13.0</string>
    <key>UIDeviceFamily</key>
    <array>
        <integer>1</integer>
    </array>
    <key>UILaunchStoryboardName</key>
    <string>LaunchScreen</string>
    <key>UIMainStoryboardFile</key>
    <string>Main</string>
    <key>UIMainStoryboardFile~ipad</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>CFBundleIdentifier</key>
    <string>-----</string>
    <key>NSLocationWhenInUseUsageDescription</key>
    <array>
        <string>App would like to use location to track the exact location of the vehicle in real time. Also notify our warehouses when the driver is arriving.</string>
    </array>
    <key>NSLocationAlwaysUsageDescription</key>
    <array>
        <string>App would like to use location to track the exact location of the vehicle in real time. Also notify our warehouses when the driver is arriving.</string>
    </array>
    <key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
    <array>
        <string>App would like to use location to track the exact location of the vehicle in real time. Also notify our warehouses when the driver is arriving</string>
    </array>

【问题讨论】:

使用字符串而不是数组作为位置描述键。 【参考方案1】:

如下更新您的 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>CFBundleDisplayName</key>
    <string>----</string>
    <key>CFBundleShortVersionString</key>
    <string>1.0</string>
    <key>CFBundleVersion</key>
    <string>1.1</string>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>MinimumOSVersion</key>
    <string>13.0</string>
    <key>UIDeviceFamily</key>
    <array>
        <integer>1</integer>
    </array>
    <key>UILaunchStoryboardName</key>
    <string>LaunchScreen</string>
    <key>UIMainStoryboardFile</key>
    <string>Main</string>
    <key>UIMainStoryboardFile~ipad</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>CFBundleIdentifier</key>
    <string>-----</string>
    <key>NSLocationWhenInUseUsageDescription</key>
    <string>App would like to use location to track the exact location of the vehicle in real time. Also notify our warehouses when the driver is arriving.</string>
    <key>NSLocationAlwaysUsageDescription</key>
    <string>App would like to use location to track the exact location of the vehicle in real time. Also notify our warehouses when the driver is arriving.</string>
    <key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
    <string>App would like to use location to track the exact location of the vehicle in real time. Also notify our warehouses when the driver is arriving</string>

您需要为位置权限添加唯一的字符串并且您已将其添加到数组中。

希望它对你有用。

【讨论】:

它修复了它!它不应该在数组中。非常感谢!

以上是关于IOS 应用程序在添加时在 info.plist 中缺少目的字符串的主要内容,如果未能解决你的问题,请参考以下文章

iOS中info.plist文件的一些相关配置

如何在 iOS 的 info.plist 中添加属性

如何在 iOS 的 info.plist 中添加属性

iOS9适配 之 关于info.plist 第三方登录 添加URL Schemes白名单

iOS9适配 之 关于info.plist 第三方登录 添加URL Schemes白名单

PhoneGap:修改 config.xml 以将属性添加到 Info.plist ion iOS