Flutter ios一键三连脚本

flutter运行ios时总得执行三个命令,中间还得等待,有没有脚本自动执行

bash 复制代码
## ios 执行命令
- flutter clean
- flutter pub get
- cd ios
- pod install

有,项目根目录创建shell 文件夹,新建setup.sh

setup.sh里面放如下代码

bash 复制代码
#!/bin/bash

# ios 一键三连
set -e

# Save current directory
current_dir=$(pwd)

# Clean the Flutter project
echo "Cleaning Flutter project..."
flutter clean

# Get all the dependencies
echo "Getting dependencies..."
flutter pub get

# Navigate to the iOS directory which is assumed to be at the parent directory of where the script is located
echo "Navigating to the iOS directory..."
cd ..

if [ -d "ios" ]; then
  cd ios
  
  # Install CocoaPods dependencies
  echo "Installing CocoaPods dependencies..."
  pod install

  # Go back to the original directory
  cd "$current_dir"
  echo "Setup completed successfully."
else
  echo "Error: 'ios' directory does not exist."
fi

运行命令,会看到自动执行一键三连

bash 复制代码
cd shell
执行 ./setup.sh

还可以扩展比如总是要生成代码用 flutter pub run build_runner build

可以加到脚本,新建build.sh放如下代码

bash 复制代码
#!/bin/bash

echo "开始生成代码"
flutter pub run build_runner build 
#flutter pub run build_runner build --delete-conflicting-outputs

运行

bash 复制代码
cd shell
执行 ./build.sh
相关推荐
北京自在科技1 小时前
苹果折叠屏iPhone突破折痕难题 或将在2026年发布
ios·iphone·findmy·折叠屏·库克
一粒沙-1 小时前
iOS 将GIF图分享至微信
前端·ios
Mamong11 小时前
Metal 学习笔记三:渲染管线
ios·swift·metal
yidahis15 小时前
用DeepSeek学源码-SDImageCodersManager 中的工厂模式解析
ios·源码
xinyu39118 小时前
iOS Framework代码中加载图片资源
macos·ios·cocoa
l软件定制开发工作室18 小时前
Flutter系列教程之(5)——常用控件Widget的使用示例
flutter
leluckys18 小时前
flutter 专题 八十五 Flutter 应用调试
flutter
ClaNNEd@18 小时前
Flutter&JSON
flutter·json
键盘敲没电18 小时前
【iOS】小蓝书学习(四)
学习·ios·cocoa
阿长长啊1 天前
Flutter 介绍及安装使用
flutter