03 Apr 2020 - Tom McFarlin
How to create a Flutter plugin that includes platform-specific Java / Objective-C code
project=gsbridge
org=com.lamptom.$project
flutter create --org $org --template=plugin -i objc -a java $project
cd $project/example
flutter build ios --no-codesign
In Xcode, open $project/example/ios
Follow official docs
Install pods
cd ios
pod install
Open main project dir in Android Studio
Open android/…/*Plugin.java
Click “edit in Android Studio” in top right
Run example app
Follow official instructions. To show the ObjC/Java code, you may need to inspect the html, remove the “active” class on the Swift/Kotlin divs and add “active” to the ObjC/Java tabs. If so, run the following in the javascript console:
document.querySelector("#ios-channel-swift-tab").classList.remove("active");
document.querySelector("#ios-channel-objective-c-tab").classList.add("active");
Follow GS SDK setup for Android. Add all gradle lines to /build.gradle not example/build.gradle or example/*/build.gradle.
In AndroidManifest make these updates:
<application ... tools:replace="android:icon,android:label">
...
<manifest ... xmlns:tools="http://schemas.android.com/tools">
Run
If you have questions or comments, please send a reply on Twitter