flutter-permission-handler icon indicating copy to clipboard operation
flutter-permission-handler copied to clipboard

iOS remove of permissions

Open danysz opened this issue 5 years ago • 8 comments

🔙 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 Pod file"

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

danysz avatar Apr 18 '20 08:04 danysz

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.

mvanbeusekom avatar May 01 '20 06:05 mvanbeusekom

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.

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.

Screenshot 2020-05-02 at 16 58 55

MichaelM97 avatar May 02 '20 16:05 MichaelM97

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.

mvanbeusekom avatar May 03 '20 10:05 mvanbeusekom

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.

Screenshot 2020-05-03 at 12 41 59

I will have to take a look at this again later today

MichaelM97 avatar May 03 '20 11:05 MichaelM97

@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)

Screenshot 2020-05-03 at 15 30 01

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.

Screenshot 2020-05-03 at 15 38 21

MichaelM97 avatar May 03 '20 14:05 MichaelM97

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.

djmuhlestein avatar May 07 '20 17:05 djmuhlestein

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.

orestesgaolin avatar May 11 '20 12:05 orestesgaolin

same here in GCC_PREPROCESSING_DEFINITIONS

ahmedqais6 avatar Jun 13 '22 11:06 ahmedqais6

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,

TimHoogstrate avatar Aug 24 '23 06:08 TimHoogstrate