Inject plugin registration. (#9216)
Added a PluginRegistry to the new project template. The registry files will be automatically updated at build time to register the native plugins. Fixes #7814.
This commit is contained in:
@@ -2,16 +2,15 @@ package {{androidIdentifier}};
|
||||
|
||||
import android.os.Bundle;
|
||||
import io.flutter.app.FlutterActivity;
|
||||
{{#withPluginHook}}
|
||||
import {{androidPluginIdentifier}}.{{pluginClass}};
|
||||
{{/withPluginHook}}
|
||||
import io.flutter.plugins.PluginRegistry;
|
||||
|
||||
public class MainActivity extends FlutterActivity {
|
||||
PluginRegistry pluginRegistry;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
{{#withPluginHook}}
|
||||
{{pluginClass}}.register(this);
|
||||
{{/withPluginHook}}
|
||||
pluginRegistry = new PluginRegistry();
|
||||
pluginRegistry.registerAll(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
1498D2341E8E89220040F4C2 /* PluginRegistry.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* PluginRegistry.m */; };
|
||||
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
|
||||
3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; };
|
||||
3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
@@ -39,6 +40,8 @@
|
||||
/* End PBXCopyFilesBuildPhase section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
1498D2321E8E86230040F4C2 /* PluginRegistry.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PluginRegistry.h; sourceTree = "<group>"; };
|
||||
1498D2331E8E89220040F4C2 /* PluginRegistry.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PluginRegistry.m; sourceTree = "<group>"; };
|
||||
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
|
||||
3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = "<group>"; };
|
||||
4D558BB7489B1C82B42A9097 /* libPods-Runner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Runner.a"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
@@ -121,6 +124,8 @@
|
||||
97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */,
|
||||
97C147021CF9000F007C117D /* Info.plist */,
|
||||
97C146F11CF9000F007C117D /* Supporting Files */,
|
||||
1498D2321E8E86230040F4C2 /* PluginRegistry.h */,
|
||||
1498D2331E8E89220040F4C2 /* PluginRegistry.m */,
|
||||
);
|
||||
path = Runner;
|
||||
sourceTree = "<group>";
|
||||
@@ -299,6 +304,7 @@
|
||||
files = (
|
||||
978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */,
|
||||
97C146F31CF9000F007C117D /* main.m in Sources */,
|
||||
1498D2341E8E89220040F4C2 /* PluginRegistry.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
||||
@@ -1,23 +1,16 @@
|
||||
#include "AppDelegate.h"
|
||||
{{#withPluginHook}}
|
||||
#include "{{pluginClass}}.h"
|
||||
#include "PluginRegistry.h"
|
||||
|
||||
@implementation AppDelegate {
|
||||
{{pluginClass}} *_{{pluginProjectName}};
|
||||
PluginRegistry *plugins;
|
||||
}
|
||||
{{/withPluginHook}}
|
||||
{{^withPluginHook}}
|
||||
@implementation AppDelegate
|
||||
{{/withPluginHook}}
|
||||
|
||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
||||
// Override point for customization after application launch.
|
||||
{{#withPluginHook}}
|
||||
// Override point for customization after application launch.
|
||||
FlutterViewController *flutterController =
|
||||
(FlutterViewController *)self.window.rootViewController;
|
||||
_{{pluginProjectName}} = [[{{pluginClass}} alloc] initWithController:flutterController];
|
||||
{{/withPluginHook}}
|
||||
return YES;
|
||||
plugins = [[PluginRegistry alloc] initWithController:flutterController];
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)applicationWillResignActive:(UIApplication *)application {
|
||||
Reference in New Issue
Block a user