Create a Flutter Plugin

Create the Flutter Plugin using Android Studio

This is the Plugin file directory created by Flutter:

The iOS directory is the iOS plugin, and the Android directory is the Android plugin. The Example directory is where we need to write code.

Introduction of pod library

Open the iOS directory in the Flutter root directory

Find the.podspec file

# # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html. # Run `pod lib lint flutter_plugin_demo.podspec` to validate before publishing. # Pod::Spec.new do |s| s.name = 'flutter_plugin_demo' Epage = '0.0.1' s.continent = 'A new Flutter project.' s.description = << -desc A new Flutter project = 'http://example.com' s.license = { :file => '.. /LICENSE' } s.author = { 'Your Company' => '[email protected]' } s.source = { :path => '.' } s.source_files = 'Classes/**/*' s.public_header_files = 'Classes/**/*.h' s.dependency 'Flutter' s.platform = :ios, '8.0' # Flutter. Framework does not contain an i386 slice.s.po_target_xcconfig = {'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' } endCopy the code

Add a private library to s.dependency ‘CZFileTransporter’ underneath s.dependency ‘Flutter’ between s.dependency = :ios, ‘8.0’

# # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html. # Run `pod lib lint flutter_transporter.podspec` to validate before publishing. # Pod::Spec.new do |s| s.name = 'flutter_transporter' Epage = '0.0.1' s.continent = 'A new Flutter project.' s.description = << -desc A new Flutter project = 'http://example.com' s.license = { :file => '.. /LICENSE' } s.author = { 'Your Company' => '[email protected]' } s.source = { :path => '.' } s.source_files = 'Classes/**/*' s.public_header_files = 'Classes/**/*.h' s.dependency 'Flutter' s.dependency 'CZFileTransporter' s.platform = :ios, '8.0' # Flutter. Framework does not contain an i386 slice.s.po_target_xcconfig = {'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' } endCopy the code

So that’s the first step.

Add a private library address

Go to the example directory, go to the iOS directory, find the podFile file, open it and add the address:

Finally, pod Install ends.