问题
I'm working on iOS simulator and am facing issues for requesting permissions.
My app was working properly and it could access to photo library, camera and location service. But after installing new XCode (8.1), I run the app on simulator, the app is not allowed to use photo library or camera or location service any more.
I tried to ask the permission programmatically, but it did not show permission request dialog and always return denied status even though I added the privacy descriptions and bundle display name.
回答1:
I found the issue. This is because your Xcode is not put in Applications folder. Move Xcode to this folder and enjoy.
回答2:
Make sure your .plist
looks like this
<key>NSCameraUsageDescription</key>
<string>This app needs access to the camera to take photos.</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>This app needs access to photos.</string>
And also if you disabled any changes to photo library privacy in your restrictions your app won't be able to use your photo library (it won't even ask for permission) until you turn off restrictions.
回答3:
Try to delete the simulator in ~/Library/Developer/CoreSimulator/Devices/xxxxx-xxx-xxxx
, and copy a new one from other machine
来源:https://stackoverflow.com/questions/40386819/ios-simulator-permission-denied-and-not-showing-permission-alert-dialog