info plist写入权限描述问题,在构建时忽略

问题描述 投票:0回答:2

应用程序启动时因错误而崩溃

"[access] This app has crashed because it attempted to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSMicrophoneUsageDescription key with a string value explaining to the user how the app uses this data."

但是我有使用说明的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>CFBundleDevelopmentRegion</key>
    <string>en</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.5</string>
    <key>CFBundleSignature</key>
    <string>????</string>
    <key>CFBundleVersion</key>
    <string>19</string>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>NSMicrophoneUsageDescription</key>
    <string>App need use microphone to measure SPL level</string>
    <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>
        <string>UIInterfaceOrientationPortraitUpsideDown</string>
    </array>
    <key>UISupportedInterfaceOrientations~ipad</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationPortraitUpsideDown</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
</dict>
</plist>

但是在启动时仍然崩溃,并出现相同的错误。当我尝试寻求用户许可时,它也崩溃了。

switch ([[AVAudioSession sharedInstance] recordPermission]) {
case AVAudioSessionRecordPermissionGranted:
    break;
case AVAudioSessionRecordPermissionDenied:
    break;
case AVAudioSessionRecordPermissionUndetermined:
    // This is the initial state before a user has made any choice
    // You can use this spot to request permission here if you want
    [[AVAudioSession sharedInstance]requestRecordPermission:^(BOOL granted) {
        // Check for granted
    }];
    break;
default:
    break;
}

我现在使用Xcode 11。在此之前,我尝试使用xcode 10更新此应用程序并在info.plist中本地化描述,但是此后xcode10无法构建。就像Xcode 10中的某种bug。

ios xcode permissions plist xcode11
2个回答
0
投票
清理内部版本应解决该问题,并删除该应用并重新运行。 NSMicrophoneUsageDescription是您的用例唯一需要添加的密钥。我只是测试了一个示例应用程序,并且运行良好。唯一的区别是快速vs Objc

0
投票
好我发现了问题,当您尝试本地化Info.plist时,这是Xcode中的错误,您必须只设置实际plist文件夹的正确路径/app/Base.lproj/Info.plist

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.