Baseflow / Baseflow/flutter-permission-handler

[app-to-app] Document how to integrate in iOS add-to-app scenario using Frameworks

Open
#682 6 comments 7 reactions 0 assignees View on GitHub
group: app-to-app P2 platform: ios type: documentation type: enhancement
Dominant language
Dart
Stars
2.2k
Forks
970
Avg merge
14h 22m
Merged PRs (30d)
2

Description

## 🏗 Enhancement Proposal

Better document how to edit the Podfile with an add-to-app using Frameworks Embedding ([Option B of integration](https://flutter.dev/docs/development/add-to-app/ios/project-setup#option-b---embed-frameworks-in-xcode))

### Pitch

Our team chose to build our Flutter Module separately from the main project to speed up build times by using cached Frameworks.

When integrating `permission_handler`, we wrongly added `GCC_PREPROCESSOR_DEFINITIONS` flags to the root project instead of in the module package.

This wasn't picked up by the permission handler build, so we had to move it to the Flutter Module Podfile, which shouldn't even be originaly committed

The way we documented it was like this:

Our internal documentation

For the Flutter module to check for permissions, it uses the `permission_handler`
plugin. As the plugin can handle all types of permissions, Apple may detect as if
the app depends on all types of weird permissions (location, wifi, etc).

To fix this, you need to add the following **to the `Podfile` of the Flutter Module**:

```ruby
post_install do |installer|
installer.pods_project.targets.each do |target|
# Other Flutter commands such as flutter_additional_ios_build_settings(target)

if target.name == 'permission_handler'
target.build_configurations.each do |config|
# Preprocessor definitions can be found in: https://github.com/Baseflow/flutter-permission-handler/blob/master/permission_handler/ios/Classes/PermissionHandlerEnums.h
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
'$(inherited)',

## dart: PermissionGroup.camera
'PERMISSION_CAMERA=1'
]
end
end
end
end
```

> ❗️ you should add this to **the Podfile which builds the Flutter plugins**.
> If you embed Flutter directly on the root project, add it there.
>
> If it is done separately (by building and embedding Frameworks manually),
> add it to the `Podfile` of the Flutter module. _This is usually not committed to the repository_,
> but must be included for the module to work properly.

### Platforms affected (mark all that apply)
- [x] :iphone: iOS
- [ ] :robot: Android

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.