I'm developing a Flutter app that relies on several external libraries. I don't use the camera in the app, however when I try to submit the app to AppStoreConnect, Apple rejects my app because they say that I don't have the NSCameraUsageDescription in my Info.plist file. Since I'm not using it directly in my app, it must be an external library. Is there a way to understand what is the library that is requesting this permission?
Run this command:
flutter pub deps | grep permission_handler
If you get any output at all, then the package is being pulled in. IF that is the package that's requesting permissions, there is a way to customize exclude/disable the imported permission libraries, in your Podfile
. Find this section:
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
... (you may have additional customizations here)
end
end
And add some flags to disable those permissions, by adding a flag such as 'PERMISSION_CAMERA=0',
to the permissions you want to disable, like so:
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
target.build_configurations.each do |config| # <-- start adding from here
# You can remove unused permissions here
# for more infomation: https://github.com/BaseflowIT/flutter-permission-handler/blob/develop/permission_handler/ios/Classes/PermissionHandlerEnums.h
# e.g. when you don't need camera permission, just add 'PERMISSION_CAMERA=0'
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
'$(inherited)',
## dart: PermissionGroup.calendar
'PERMISSION_EVENTS=0',
## dart: PermissionGroup.reminders
'PERMISSION_REMINDERS=0',
## dart: PermissionGroup.contacts
# 'PERMISSION_CONTACTS=0',
## dart: PermissionGroup.camera
# 'PERMISSION_CAMERA=0',
## dart: PermissionGroup.microphone
'PERMISSION_MICROPHONE=0',
## dart: PermissionGroup.speech
'PERMISSION_SPEECH_RECOGNIZER=0',
## dart: PermissionGroup.photos
# 'PERMISSION_PHOTOS=0',
## dart: [PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse]
'PERMISSION_LOCATION=0',
## dart: PermissionGroup.notification
# 'PERMISSION_NOTIFICATIONS=0',
## dart: PermissionGroup.mediaLibrary
'PERMISSION_MEDIA_LIBRARY=0',
## dart: PermissionGroup.sensors
'PERMISSION_SENSORS=0',
## dart: PermissionGroup.bluetooth
'PERMISSION_BLUETOOTH=0'
]
end # <-- end adding here
end
end
In the example above, I've commented out (because my apps uses them) contacts, camera, photos, and notifications; and disables all the other permissions.
Hopefully permission_handler is the package requesting the permission, because they make it easy to fix.