上一篇簡單的整理了一下Podspec語法整理,主要是爲了這一篇Flutter中iOS原生模塊開發。html
在開發Flutte中咱們不免會遇到原生組件、插件或者與原生模塊通訊,好比地圖、引入第三方sdk如微信、支付寶等SDK,還有攝像頭SDK,咱們必需要用到原生, 固然你也能夠用pub.dev/flutter中的,可是這並非最終的解決之道,Flutter剛發展不久,假如恰好沒有或者並不知足你的需求,所以這就須要本身動手,俗話說本身動手豐衣足食ios
這種方法比較簡單就像iOS項目中直接引用,前提是pod search能夠搜索到它。c++
#
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html
#
Pod::Spec.new do |s|
s.name = 'flutter_txmap_plugin'
s.version = '0.0.1'
s.summary = '一款騰訊地圖Flutter插件'
s.description = <<-DESC
一款騰訊地圖Flutter插件
DESC
s.homepage = 'http://example.com'
s.license = { :file => '../LICENSE' }
s.author = { 'Your Company' => 'my_snail@126.com' }
s.source = { :path => '.' }
s.source_files = 'Classes/**/*'
s.public_header_files = 'Classes/**/*.h'
s.dependency 'Flutter'
## 引入,還能夠攜帶版本號
s.dependency 'AFNetworking', '~> 1.0'
s.ios.deployment_target = '9.0'
end
複製代碼
這種方法咱們不能夠像第一種直接引入,由於pod search根本搜索不到,好比騰訊地圖,遇到這種方式的話只有下載他們的庫,而後引入,例如:sql
#
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html
#
Pod::Spec.new do |s|
s.name = 'flutter_txmap_plugin'
s.version = '0.0.1'
s.summary = '一款騰訊地圖Flutter插件'
s.description = <<-DESC
一款騰訊地圖Flutter插件
DESC
s.homepage = 'http://example.com'
s.license = { :file => '../LICENSE' }
s.author = { 'Your Company' => 'my_snail@126.com' }
s.source = { :path => '.' }
s.source_files = 'Classes/**/*'
s.public_header_files = 'Classes/**/*.h'
s.dependency 'Flutter'
# 引入資源,好比咱們想要顯示標註的圖片
s.resources = ['Images/*.png']
# 騰訊地圖的framework庫,pod search搜索的應該是很早的版本和最新的api對應不上
s.vendored_frameworks = 'Frameworks/QMapKit.framework', 'Frameworks/TencentLBS.framework'
s.ios.deployment_target = '9.0'
end
複製代碼
.a
文件最近在引入一個攝像頭sdk和配置設備到Wi-Fi下面,都是.a的庫,這種方式又是如何引入了,也是搞了很久,終於在guides.cocoapods.org/syntax/pods…中找到了 以下:api
#
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html
#
Pod::Spec.new do |s|
s.name = 'erazl_plugin'
s.version = '0.0.1'
s.summary = 'A new flutter plugin project.'
s.description = <<-DESC
A new flutter plugin 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', 'Library/*.h'
# 引入Library文件夾下全部的*.a庫
s.vendored_libraries = 'Library/*.a'
s.frameworks = 'MobileCoreServices', 'CFNetwork', 'CoreGraphics'
# 只是引入*.a庫仍是不行,仍是要引入相關聯的系統庫,不然沒法編譯經過
# 用戶目標(應用程序)須要連接的系統庫列表,
s.libraries = 'z.1.2.5', 'c++', 'c', 'iconv.2.4.0', 'sqlite3', 'stdc++.6.0.9', 'xml2', 'bz2.1.0', 'resolv', 'xml2', 'z'
s.dependency 'Flutter'
s.ios.deployment_target = '9.0'
end
複製代碼
上訴就是最近在開發iOS原生模塊時遇到的各類問題,在此作個簡單的總結,若是還有其餘方式歡迎互相學習bash