创建Flutter module
flutter create --template module my_flutter
APP集成
在Podfile里面添加如下代码:
flutter_application_path = 'path/to/my_flutter/'
load File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb')
target 'MyApp' do
install_all_flutter_pods(flutter_application_path)
end
target 'MyAppTests' do
install_all_flutter_pods(flutter_application_path)
end
参考自 https://www.cnblogs.com/jukaiit/p/12181184.html
打包脚本
最简单的来说 APP集成的是 App.framework
和 Flutter.framework
有这两个文件团队其他成员就可以集成Flutter了。
这两个文件的生成也很简单,用命令flutter build ios
即可,生成的framework在你创建的Flutter工程的一个隐藏文件夹(.ios)里面。
我们只需要这几个文件,当然这几个文件我们需要把它copy出来放到pod仓库指定目录,这里我们可以用脚本完成。build_path
自己修改,后面私有pod库建完之后,可以直接填写pod库的路径。release版本还是debug版本自己选择,debug用于模拟器调试,release用于真机调试或者打包。
#!/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 --debug
echo "构建 release 已完成"
echo "开始 处理framework和资源文件"
build_path="../FlutterMixDemo/build_flutter_ios"
if [ -d ${build_path} ]; then
find ${build_path} -name \*.framework | xargs rm -rf
#find ${build_path} -name \*.h | xargs rm -rf
#find ${build_path} -name \*.m | 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}
# cd ../FlutterMixDemo
# pod install
echo done
网友评论