创建Flutter Plugin
使用Android Studio 创建Flutter Plugin
下图是 Flutter 创建出来的Plugin文件目录:
其中iOS目录是iOS的plugin,android目录是android的plugin。
example目录是我们需要编写代码的地方。
引入pod库
打开Flutter根目录中的iOS目录
找到 .podspec文件
#
# 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'
s.version = '0.0.1'
s.summary = 'A new Flutter project.'
s.description = <<-DESC
A new Flutter project.
DESC
s.homepage = 'http://example.com'
s.license = { :file => '../LICENSE' }
s.author = { 'Your Company' => 'email@example.com' }
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 a i386 slice.
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' }
end
复制代码
我们在s.dependency 'Flutter'
下方,s.platform = :ios, '8.0'
中间添加上私有库s.dependency 'CZFileTransporter'
#
# 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'
s.version = '0.0.1'
s.summary = 'A new Flutter project.'
s.description = <<-DESC
A new Flutter project.
DESC
s.homepage = 'http://example.com'
s.license = { :file => '../LICENSE' }
s.author = { 'Your Company' => 'email@example.com' }
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 a i386 slice.
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' }
end
复制代码
这样第一步就好了。
添加私有库地址
进入example目录中,找到iOS目录,找到podfile文件,打开并添加地址:
最后pod install 就结束了。
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END