Flutter

Flutter 组件化导入现有 iOS 项目

2019-12-25  本文已影响0人  iVikings

Flutter项目实战:方案有三

也就可以看出最简单的方法就是将 Flutter 项目进行相对应打包,产生产物分别对应 iOS 和安卓进行组件化生成,也就完成了Flutter现有项目的开发,同时也不会对现有原生项目产生较大影响的方法是最为可行的。

#!/bin/sh
#终端输入 echo $PATH 查看PATH路径
# chmod 755 build.sh 获取权限
#PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
#export PATH
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8

echo "Clean old build"
find . -d -name "build" | xargs rm -rf
#flutter clean

echo "开始获取 packages 插件资源"
flutter packages get

echo "开始构建 release for ios"
flutter build ios
echo "构建 release 已完成"
echo "开始 处理framework和资源文件"

build_path="../build_flutter_weiboad_ios"
if [ -d ${build_path} ]; then
find ${build_path} -name \*.framework | xargs rm -rf
else
mkdir ${build_path}
fi

cp -r build/ios/Release-iphoneos/*/*.framework ${build_path}
cp -r .ios/Flutter/App.framework ${build_path}
cp -r .ios/Flutter/engine/Flutter.framework ${build_path}
#cp -r .ios/Flutter/FlutterPluginRegistrant/Classes/GeneratedPluginRegistrant.* ${build_path}

#下一步处理 如何自动生成podspec
#下下一步处理 如何自动发布pod

echo done

默认的 iOS build 是打的 release,如果要打 debug 包,可以在 flutter build ios 后面加 --debug

Pod::Spec.new do |spec|
  spec.name         = "weibo_ad_flutter_sdk"
  spec.version      = "0.0.1"
  spec.summary      = "A short description of weibo_ad_flutter_sdk."

  spec.description  = <<-DESC
  weibo ad flutter sdk
                   DESC

  spec.homepage     = 'http://git.intra.weibo.com/ad/mobile/WBKit'
  spec.license      = { :type => 'MIT', :file => 'LICENSE' }
  spec.author       = { "**" => "**@*.*.com" }

  spec.platform     = :ios, "9.0"
  spec.requires_arc = true

  spec.source        = { :git => '', :tag => "#{spec.version}" }
  #spec.source_files  = "**/*.{h,m}"
  spec.ios.vendored_frameworks = "**/*.framework"

end

参考:

上一篇下一篇

猜你喜欢

热点阅读