【问题标题】:Problem with info plist write permission description, ignoring at build信息 plist 写入权限描述的问题,在构建时忽略
【发布时间】:2020-07-17 22:38:38
【问题描述】:

应用程序在启动时崩溃并出现错误

"[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 中的某种错误。

【问题讨论】:

    标签: ios xcode permissions plist xcode11


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:

      干净的构建应该可以解决问题,并删除应用程序并重新运行。 NSMicrophoneUsageDescription 是唯一需要为您的用例添加的键。我刚刚测试了一个示例应用程序并且工作得很好。唯一的区别是 swift vs Objc

      【讨论】:

      • 谢谢,但还是不行,是关键,但是崩溃日志中的这个字符串“应用程序的 Info.plist 必须包含一个 NSMicrophoneUsageDescription”
      • 我认为一种可能的方法是创建新的应用项目并使用故事板复制源代码
      猜你喜欢
      • 2021-07-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-15
      • 2023-04-07
      • 1970-01-01
      • 2011-06-05
      • 1970-01-01
      相关资源
      最近更新 更多