我正在开发一个依赖于几个外部库的Flutter应用程序。我不在应用程序中使用相机,但当我试图将应用程序提交到AppStoreConnect时,苹果拒绝了我的应用程序,因为他们说我的Info.plist文件中没有NSCameraUsageDescription。由于我没有直接在我的应用程序中使用它,所以它必须是一个外部库。有没有办法了解请求此权限的库是什么?
运行此命令:
flutter pub deps | grep permission_handler
如果您得到任何输出,则该包将被拉入。如果是请求权限的包,则有一种方法可以在Podfile
中自定义排除/禁用导入的权限库。查找此部分:
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
并添加一些标志来禁用这些权限,方法是在要禁用的权限中添加'PERMISSION_CAMERA=0',
等标志,如下所示:
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
在上面的例子中,我已经评论掉了(因为我的应用程序使用了它们(联系人、相机、照片和通知;并禁用所有其他权限。
希望permission_handler是请求权限的包,因为它们使修复变得容易。