如何知道哪些库在 Flutter 中请求特定的 iOS 权限?
How to know what library requests particular iOS permissions in Flutter?
我正在开发一个依赖于多个外部库的 Flutter 应用程序。我没有在应用程序中使用相机,但是当我尝试将应用程序提交到 AppStoreConnect 时,Apple 拒绝了我的应用程序,因为他们说我的 Info.plist 文件中没有 NSCameraUsageDescription。由于我没有在我的应用程序中直接使用它,它一定是一个外部库。有没有办法了解请求此权限的库是什么?
运行 这个命令:
flutter pub deps | grep permission_handler
如果你得到任何输出,那么包被拉入。IF 那是请求权限的包,有一种方法可以自定义 exclude/disable 导入的许可库,在您的 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 是请求权限的包,因为它们很容易修复。
我正在开发一个依赖于多个外部库的 Flutter 应用程序。我没有在应用程序中使用相机,但是当我尝试将应用程序提交到 AppStoreConnect 时,Apple 拒绝了我的应用程序,因为他们说我的 Info.plist 文件中没有 NSCameraUsageDescription。由于我没有在我的应用程序中直接使用它,它一定是一个外部库。有没有办法了解请求此权限的库是什么?
运行 这个命令:
flutter pub deps | grep permission_handler
如果你得到任何输出,那么包被拉入。IF 那是请求权限的包,有一种方法可以自定义 exclude/disable 导入的许可库,在您的 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 是请求权限的包,因为它们很容易修复。