flutter-permission-handler
                                
                                 flutter-permission-handler copied to clipboard
                                
                                    flutter-permission-handler copied to clipboard
                            
                            
                            
                        iOS remove of permissions
🔙 Regression
Now we need to "remove" the permissions we don't need in iOS using the Pod file. The problem with that is that the Pod file for iOS in Flutter projects is not a file which "have" to be stored in the version control.
The Pod file is automatically recreated and update when the iOS version is build. Also Flutter team suggest for some issues
"remove the
Podfile"
as a solution. Version: 5.x
I suggest to have an "external" configuration file which should be stored or something else and not the Pod file
Platform:
- [x] :iphone: iOS
Hi @danysz, at the moment I am not very familiar with the Xcode build configuration. The code you need to add to the podfile ensures that before the iOS code is compiled some macros will be set, which in turn make sure certain parts of the code base is not compiled and thus omitted from the final binary.
I am not sure how we could accomplish this using a external configuration file. There needs to be a hook into the compile process and be able to turn on these macros. If you have any suggestions please let me know.
Second I am a bit surprised be your statement the Flutter would suggest to remove the Podfile file. Do you have any examples of this? I know that sometimes it is suggested to delete the Podfile.lock file but never really the Podfile it self.
Hi @danysz, at the moment I am not very familiar with the Xcode build configuration. The code you need to add to the podfile ensures that before the iOS code is compiled some macros will be set, which in turn make sure certain parts of the code base is not compiled and thus omitted from the final binary.
I am not sure how we could accomplish this using a external configuration file. There needs to be a hook into the compile process and be able to turn on these macros. If you have any suggestions please let me know.
Second I am a bit surprised be your statement the Flutter would suggest to remove the
Podfilefile. Do you have any examples of this? I know that sometimes it is suggested to delete thePodfile.lockfile but never really thePodfileit self.
This could be achieved by using a Build Phase Run Script, for example, I currently use one to switch which GoogleService-Info.plist to use depending on which Firebase environment the app should point at, which is done pre-compilation.
 
                                    
                                    
                                    
                                
Hi @MichaelM97, thank you for offering a suggestion. Would you be able to give me some information on how I would write such a script? Maybe you could point me to some resources?
I am not familiar with Xcode build system so any information which would help me to understand this would be appreciated and I will try to create such a script.
Hi @MichaelM97, thank you for offering a suggestion. Would you be able to give me some information on how I would write such a script? Maybe you could point me to some resources?
I am not familiar with Xcode build system so any information which would help me to understand this would be appreciated and I will try to create such a script.
There's a decent guide on how to create a script here
I've been trying to create one for this purpose, however, I'm having issues creating a reference to GCC_PREPROCESSOR_DEFINITIONS.
Flutter has a run script at $FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh which references ENABLE_BITCODE in the image below, but I can't seem to modify GCC_PREPROCESSOR_DEFINITIONS by referencing it in this way.
 
I will have to take a look at this again later today
@mvanbeusekom A simpler alternative to a Build Phase may just be adding these exclusions to all defined schema in XCode -> Runner -> Build Settings. I definitley think that the PodFile approach is simpler, but this is an alternative for those that need it (like @danysz).
Below is a screenshot showing where these would be added for an app that has a dev and production build flavour. As most will have no build flavours setup, they would just need to add the exclusions to Debug, Profile, and Release. (Note that you can search for GCC_PREPROCESSOR_DEFINITIONS to make finding this setting easier)
 
That method is a little time consuming as you can't copy and paste, so you could just search through PROJECT/ios/Runner.xcodeproj/project.pbxproj for all instances of GCC_PREPROCESSOR_DEFINITIONS and update them there.
 
                                    
                                    
                                    
                                
This isn't working for me to add GCC_PREPROCESSING_DEFINITIONS to the Target or the Project. Either way, the pod is still being compiled without those macros. If I edit the pods xcconfig file instead (permission_handler.release.xcconfig), the settings will be applied. That isn't preferable though of course since that is generated. I seem to be missing the proper way to get the pod to be compiled with my custom preprocessor definitions.
EDIT: If I put the macro in the Pods.xcconfig file, it also works, so it appears Pods is not inheriting from my Runner project. Unsure if something with my project isn't set up correctly.
Same as @djmuhlestein adding GCC_PREPROCESSING_DEFINITIONS in iOS project doesn't work for me. I cannot add them to my Pods project as it's regenerated every time.
same here in GCC_PREPROCESSING_DEFINITIONS
It seems that this issue has been resolved. Feel free to reopen or create a new issue when new information pops-up. Don't forget to place the output of flutter doctor -v and some minimal reproducible code or steps to reproduce in that issue.
Kind regards,