Support podspec module_name to avoid name clash with native iOS frameworks #63240
Labels
a: plugins
Support for writing, building, and running plugin packages
c: proposal
A detailed proposal for a change to Flutter
dependency: dart
Dart team may need to help us
P3
Issues that are less important to the Flutter project
platform-ios
iOS applications specifically
team-ios
Owned by iOS platform team
tool
Affects the "flutter" command-line tool. See also t: labels.
triaged-ios
Triaged by iOS platform team
Use case
A recent update to flutter (on master, not sure if it has reached other branches yet) has broken a plugin I use, Objectbox. The issue is that they have a native package called 'objectbox' which is included by the dart plugin. Before this version they were able to get away without having any objc/swift code and therefore didn't have a framework, and so there was no name collision. However, with the new changes in master it seems as though having a plugin implementation is required.
They could theoretically get around this by publishing a separate package, but that seems really silly and leads to package bloat on pub.dev as well as more difficulty for whoever is maintaining it.
Proposal
Instead, I'd like to propose supporting something that cocoapods has support for - setting the
s.module_name
. If this is set to something else, it eliminates the collision with the native package (i.e. objectboxdart). However, in the GeneratedPluginRegistrant.m file, it always generates it with name 'objecbox'.If the flutter tooling supports it, it'd be great if it could be read from the podspec, but I'm going to guess that'd not possible so a perfectly great alternative would be the ability to define it directly in the pubspec.yaml for the package, something like this:
I've been able to get a project including the plugin to compile by adding this to the objectbox.podspec:
And the only thing that needs changing is the GeneratePluginRegistrant.m file:
It might make sense for the symlinks etc to be changed as well (so that it'd be
objectgboxdart/ObjectboxPlugin.h
in the above, but being able to change the@import
statement is enough to get it working for me.With this change implemented, if the
moduleName
isn't defined, it could default to the package name exactly as it does now. This would allow for easy overlap with native frameworks that have the same name as the flutter packages.The text was updated successfully, but these errors were encountered: