Unverified Commit e69b4346 authored by Mikkel Nygaard Ravn's avatar Mikkel Nygaard Ravn Committed by GitHub

Fix broken Flutter module with plugins (#20496)

parent ba723b60
...@@ -31,6 +31,17 @@ Future<Null> main() async { ...@@ -31,6 +31,17 @@ Future<Null> main() async {
); );
}); });
section('Add plugins');
final File pubspec = new File(path.join(directory.path, 'hello', 'pubspec.yaml'));
String content = await pubspec.readAsString();
content = content.replaceFirst(
'\ndependencies:\n',
'\ndependencies:\n battery:\n package_info:\n',
);
await pubspec.writeAsString(content, flush: true);
section('Build Flutter module library archive'); section('Build Flutter module library archive');
await inDirectory(new Directory(path.join(directory.path, 'hello', '.android')), () async { await inDirectory(new Directory(path.join(directory.path, 'hello', '.android')), () async {
......
...@@ -148,7 +148,7 @@ class CocoaPods { ...@@ -148,7 +148,7 @@ class CocoaPods {
return true; return true;
} }
/// Ensures the `ios` sub-project of the Flutter project at [appDirectory] /// Ensures the given iOS sub-project of a parent Flutter project
/// contains a suitable `Podfile` and that its `Flutter/Xxx.xcconfig` files /// contains a suitable `Podfile` and that its `Flutter/Xxx.xcconfig` files
/// include pods configuration. /// include pods configuration.
void setupPodfile(IosProject iosProject) { void setupPodfile(IosProject iosProject) {
...@@ -156,13 +156,14 @@ class CocoaPods { ...@@ -156,13 +156,14 @@ class CocoaPods {
// Don't do anything for iOS when host platform doesn't support it. // Don't do anything for iOS when host platform doesn't support it.
return; return;
} }
if (!iosProject.directory.existsSync()) { final Directory runnerProject = iosProject.directory.childDirectory('Runner.xcodeproj');
if (!runnerProject.existsSync()) {
return; return;
} }
final File podfile = iosProject.podfile; final File podfile = iosProject.podfile;
if (!podfile.existsSync()) { if (!podfile.existsSync()) {
final bool isSwift = xcodeProjectInterpreter.getBuildSettings( final bool isSwift = xcodeProjectInterpreter.getBuildSettings(
iosProject.directory.childFile('Runner.xcodeproj').path, runnerProject.path,
'Runner', 'Runner',
).containsKey('SWIFT_VERSION'); ).containsKey('SWIFT_VERSION');
final File podfileTemplate = fs.file(fs.path.join( final File podfileTemplate = fs.file(fs.path.join(
......
...@@ -12,6 +12,7 @@ import io.flutter.plugin.common.BasicMessageChannel; ...@@ -12,6 +12,7 @@ import io.flutter.plugin.common.BasicMessageChannel;
import io.flutter.plugin.common.StringCodec; import io.flutter.plugin.common.StringCodec;
import io.flutter.view.FlutterMain; import io.flutter.view.FlutterMain;
import io.flutter.view.FlutterNativeView; import io.flutter.view.FlutterNativeView;
import io.flutter.view.FlutterRunArguments;
import io.flutter.view.FlutterView; import io.flutter.view.FlutterView;
import io.flutter.plugins.GeneratedPluginRegistrant; import io.flutter.plugins.GeneratedPluginRegistrant;
...@@ -91,8 +92,10 @@ public final class Flutter { ...@@ -91,8 +92,10 @@ public final class Flutter {
lifecycle.addObserver(new LifecycleObserver() { lifecycle.addObserver(new LifecycleObserver() {
@OnLifecycleEvent(Lifecycle.Event.ON_CREATE) @OnLifecycleEvent(Lifecycle.Event.ON_CREATE)
public void onCreate() { public void onCreate() {
final String appBundlePath = FlutterMain.findAppBundlePath(activity.getApplicationContext()); final FlutterRunArguments arguments = new FlutterRunArguments();
flutterView.runFromBundle(appBundlePath, null, "main", true); arguments.bundlePath = FlutterMain.findAppBundlePath(activity.getApplicationContext());
arguments.entrypoint = "main";
flutterView.runFromBundle(arguments);
GeneratedPluginRegistrant.registerWith(flutterView.getPluginRegistry()); GeneratedPluginRegistrant.registerWith(flutterView.getPluginRegistry());
} }
......
...@@ -46,7 +46,7 @@ void main() { ...@@ -46,7 +46,7 @@ void main() {
mockProcessManager = new MockProcessManager(); mockProcessManager = new MockProcessManager();
mockXcodeProjectInterpreter = new MockXcodeProjectInterpreter(); mockXcodeProjectInterpreter = new MockXcodeProjectInterpreter();
projectUnderTest = await FlutterProject.fromDirectory(fs.directory('project')); projectUnderTest = await FlutterProject.fromDirectory(fs.directory('project'));
projectUnderTest.ios.directory.createSync(recursive: true); projectUnderTest.ios.directory.childDirectory('Runner.xcodeproj').createSync(recursive: true);
cocoaPodsUnderTest = new CocoaPods(); cocoaPodsUnderTest = new CocoaPods();
pretendPodVersionIs('1.5.0'); pretendPodVersionIs('1.5.0');
fs.file(fs.path.join( fs.file(fs.path.join(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment