When I follow the hello-world approach in creating a Flutter plugin and adding it to another hello-world Flutter project, it all fails whenever I try to add the plugin dependency (either local with path:
or remote with git:
.
My steps are:
- I create a new Flutter project, doing the following inside a terminal:
flutter create hello_world_app
I add a large asset (> 665 MB) to my hello_world_app since I will need it inside my app.
I build and run a prototype app using my large asset inside hello_world_app. It runs without any problems.
I did create the plugin using the following terminal command:
I create a Flutter plugin writing inside a terminal:
flutter create --org com.mycomp --template=plugin -i swift large_file_copy
I do some minor changes to the newly created plugin. I can run the newly created plugin "large_file_copy" on both worlds (iOS and Android). I run it from the plugin-example folder. All works well.
I make a git repo out of the plugin and I commit all changes and push it to a public git repo.
But now, that's when things go wrong:
- I try to add the plugin to the dependencies of my hello-world project, doing the following:
Inside pubspec.yaml
of my "hello_world_app"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.2
large_file_copy:
git:
url: https://github.com/XXXXX/large_file_copy.git
The output terminal sais:
Running "flutter packages get" in my_app... 0.6s
exit code 0
Then I try to run my project. And that's the moment the App crashes.
WHY IS ADDING THE PLUGIN DEPENDENCY MAKE MY FLUTTER PROJECT CRASH ??
In fact, I can even import the plugin-package to my flutter code and call the plugin method. The compiler does not complain at this moment. But as soon as I try to build and run, that's when the app crashes...
What is wrong in the above approach ??
How do I correctly set the plugin dependency ??
Here are the two error message-logs (one for iOS and one for Android world). Again, these occur as soon as the plugin dependency is added to the pubspec.yaml file....
Error message-log for iOS:
2018-12-23 14:32:52.179 xcodebuild[56661:1181076] [MT] PluginLoading: Required plug-in compatibility UUID D76765677-CB11-4D25-A34B-E33DB5A7C231 for plug-in at path '~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/KZLinkedConsole.xcplugin' not present in DVTPlugInCompatibilityUUIDs
2018-12-23 14:32:52.179 xcodebuild[56661:1181076] [MT] PluginLoading: Required plug-in compatibility UUID D76765677-CB11-4D25-A34B-E33DB5A7C231 for plug-in at path '~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/ColorSenseRainbow.xcplugin' not present in DVTPlugInCompatibilityUUIDs
2018-12-23 14:32:52.179 xcodebuild[56661:1181076] [MT] PluginLoading: Required plug-in compatibility UUID D76765677-CB11-4D25-A34B-E33DB5A7C231 for plug-in at path '~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/BBUDebuggerTuckAway.xcplugin' not present in DVTPlugInCompatibilityUUIDs
2018-12-23 14:32:52.180 xcodebuild[56661:1181076] [MT] PluginLoading: Required plug-in compatibility UUID D76765677-CB11-4D25-A34B-E33DB5A7C231 for plug-in at path '~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/Alcatraz.xcplugin' not present in DVTPlugInCompatibilityUUIDs
** BUILD FAILED **
Xcode's output:
↳
=== BUILD TARGET sqflite OF PROJECT Pods WITH CONFIGURATION Debug ===
/Users/user/Documents/flutter/.pub-cache/git/large_file_copy-5cc22b5c6d2345ba1ab23a44324b222c68d24ab4/ios/Classes/MyPluginName.m:2:9: fatal error: 'large_file_copy/large_file_copy-Swift.h' file not found
#import < large_file_copy/large_file_copy-Swift.h>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
Could not build the application for the simulator.
Error launching application on iPhone XS.
Exited (sigterm)
. Error message-log for Android:
Launching lib/main.dart on Android SDK built for x86 in debug mode...
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:packageDebug'.
> Failed to obtain compression information for entry
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 12s
Gradle task assembleDebug failed with exit code 1
Exited (sigterm)