目录结构示例
/path/to/your/flutter_plugin
├── .git
├── example
│ ├── ios
│ │ ├── Podfile
│ │ ├── Runner.xcodeproj
│ │ ├── Runner.xcworkspace
│ │ └── ...
│ └── lib
│ └── main.dart
├── ios
│ ├── Classes
│ │ └── ...
│ ├── your_plugin.podspec
└── lib
└── your_plugin.dart
具体操作步骤如下
1.在 Flutter
插件目录中添加 Git Submodule
- 首先,导航到你的
Flutter
插件的 iOS
目录,然后添加你 fork
的第三方库作为 Git Submodule
。
cd /path/to/your/flutter_plugin/ios
git submodule add https://github.com/yourname/Charts.git Vendor/Charts
git submodule update --init --recursive
2.更新 Podspec
文件
- 在你的
Flutter
插件的 iOS
目录中找到并编辑 Podspec
文件(通常是 your_plugin.podspec
)。
# your_plugin.podspec
Pod::Spec.new do |s|
s.name = 'your_plugin'
s.version = '1.0.0'
s.summary = 'A short description of your_plugin.'
s.description = <<-DESC
A longer description of your_plugin in multiple lines.
DESC
s.homepage = 'http://example.com/your_plugin'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { 'Your Name' => 'your.email@example.com' }
s.source = { :git => 'https://github.com/yourname/your_plugin.git', :tag => s.version.to_s }
s.ios.deployment_target = '9.0'
s.source_files = 'Classes/**/*'
# Adding the forked third-party library as a submodule
s.subspec 'Charts' do |forked|
forked.source_files = 'Vendor/Charts/**/*.{h,m,swift}'
end
end
3.运行 pod install
- 在
example
项目的 iOS
目录下运行 pod install
。
cd /path/to/your/flutter_plugin/example/ios
pod install
更新完成后的目录结构示例
- 最终,你的 Flutter 插件目录结构可能如下所示:
/path/to/your/flutter_plugin
├── .git
├── .gitmodules
├── example
│ ├── ios
│ │ ├── Podfile
│ │ ├── Runner.xcodeproj
│ │ ├── Runner.xcworkspace
│ │ └── ...
│ └── lib
│ └── main.dart
├── ios
│ ├── .gitmodules
│ ├── Classes
│ │ └── ...
│ ├── your_plugin.podspec
│ └── Vendor
│ └── Charts
│ ├── .git
│ ├── SourceFiles
│ └── ...
└── lib
└── your_plugin.dart
网友评论