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
相关推荐
愚者Pro11 小时前
Flutter Widget组件学习(专为 Uniapp 转 Flutter 定制)
vue.js·学习·flutter·uni-app
sweet丶12 小时前
iOS 蓝牙开发深入总结
ios·蓝牙
Flynt13 小时前
升级Flutter 3.44,我踩了HCPP和AGP 9的坑
android·flutter·dart
程序员老刘14 小时前
Flutter 3.44 更新要点:很重要但暂时先别升级
flutter·ai编程·客户端
Digitally15 小时前
免费将 iPhone 音乐传输到电脑:6 种方法
ios·iphone
程序员老刘·18 小时前
Flutter版本选择指南:3.44惊艳发布但需观望 | 2026年5月
flutter·ai编程·跨平台开发·客户端开发
●VON18 小时前
鸿蒙Flutter实战:Emoji心情选择器组件
flutter·华为·harmonyos
●VON19 小时前
鸿蒙Flutter实战:列表延时错峰入场动画
flutter·华为·harmonyos
测试开发-学习笔记20 小时前
从0开始搭建自动化(二)-flutter
运维·flutter·自动化
●VON20 小时前
鸿蒙Flutter实战:零依赖手写日历热力图
flutter·华为·harmonyos