Flutter-permission-handler: Updating pod file now longer works

Created on 3 Aug 2020  路  9Comments  路  Source: Baseflow/flutter-permission-handler

馃敊 Regression

I had a warning saying

Warning: Podfile is out of date
  This can cause issues if your application depends on plugins that do not support iOS.
  See https://flutter.dev/docs/development/packages-and-plugins/developing-packages#plugin-platforms for details.
  If you have local Podfile edits you would like to keep, see https://github.com/flutter/flutter/issues/45197 for instructions.
To regenerate the Podfile, run:
  rm ios/Podfile

I then regenerated and the section that we have to edit to put the permissions we require has changed to this

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
  end
end

When i add my permissions below flutter_additional_ios_build_settings(target) it fails to run.... I think it errors because I no longer have the config variable, but I could be completely wrong. I have very little knowledge about iOS. Could someone help me solve this?

Version: v5.0.1+1

Platform:

  • [ X] :iphone: iOS
  • [ ] :robot: Android

Most helpful comment

Where are these steps? In Xcode? @tneotia

External Libraries > Flutter Plugins > Permission Handler > iOS > classes > PermissionHandlerEnums.h

This is in Android Studio, external libraries is an folder underneath all the flutter files in the project pane.

I don't think this is going to work when you have multiple installs or for a different machines.

You can just do that following in the post_install as mentioned here.

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
    target.build_configurations.each do |config|
      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'
        ]
     end
  end
end

All 9 comments

This happened to me after upgrading to Flutter beta 1.20. Don't know how to fix yet - it's a showstopper because now I can't upload to App Store Connect as I get errors saying permissions (that I'm not using in my app) aren't given a reason for use - I can't exclude them using the instructions in the README.

Update: Managed to fix this and successfully upload a build to App Store Connect.
Steps:
External Libraries > Flutter Plugins > Permission Handler > iOS > classes > PermissionHandlerEnums.h

In here, change the value to 0 whatever permissions you don't use in any of the #define statements. No need to add anything to Podfile, just leave it as is!

Update: Managed to fix this and successfully upload a build to App Store Connect.
Steps:
External Libraries > Flutter Plugins > Permission Handler > iOS > classes > PermissionHandlerEnums.h

In here, change the value to 0 whatever permissions you don't use in any of the #define statements. No need to add anything to Podfile, just leave it as is!

Where are these steps? In Xcode? @tneotia

External Libraries > Flutter Plugins > Permission Handler > iOS > classes > PermissionHandlerEnums.h

Where are these steps? In Xcode? @tneotia

External Libraries > Flutter Plugins > Permission Handler > iOS > classes > PermissionHandlerEnums.h

This is in Android Studio, external libraries is an folder underneath all the flutter files in the project pane.

Where are these steps? In Xcode? @tneotia

External Libraries > Flutter Plugins > Permission Handler > iOS > classes > PermissionHandlerEnums.h

This is in Android Studio, external libraries is an folder underneath all the flutter files in the project pane.

I don't think this is going to work when you have multiple installs or for a different machines.

You can just do that following in the post_install as mentioned here.

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
    target.build_configurations.each do |config|
      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'
        ]
     end
  end
end

I don't think this is going to work when you have multiple installs or for a different machines.

You can just do that following in the post_install as mentioned here.

Yes, you are completely right - it will only work on the machine you have made the change on.

I think I had tried this at first but it hadn't worked - the build threw an error. Maybe I did something wrong, I will try again and see if it works in a bit.

I don't think this is going to work when you have multiple installs or for a different machines.
You can just do that following in the post_install as mentioned here.

Yes, you are completely right - it will only work on the machine you have made the change on.

I think I had tried this at first but it hadn't worked - the build threw an error. Maybe I did something wrong, I will try again and see if it works in a bit.

Yea make sure you do flutter clean

Just got a chance to test today, and @shreymahendru 's answer works.

Thanks guys 馃憤

Was this page helpful?
0 / 5 - 0 ratings