Search code examples
iosxcodepermissionsplistxcode11

Problem with info plist write permission description, ignoring at build


App crash at startup with error

"[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."

But I have Info.plist with usage description

    <?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>

But still crashed on startup, with same error. it also crashed when I try to ask user permission.

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;
}

I use Xcode 11 now. Before that, I tried to update this app using xcode 10 and localize the descriptions in info.plist, but after that xcode10 could not build. It was like some kind of bug in Xcode 10.


Solution

  • Ok. I found problem, it was bug in Xcode when you try to localize Info.plist, You must just set correct path of your actual plist folder /app/Base.lproj/Info.plist

    enter image description here