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
相关推荐
kirk_wang18 分钟前
Flutter艺术探索-PlatformView嵌入:在Flutter中显示原生View
flutter·移动开发·flutter教程·移动开发教程
ujainu20 分钟前
Flutter for OpenHarmony 悬浮操作按钮:FloatingActionButton 与扩展菜单的深度优化实践
android·flutter·组件
向哆哆22 分钟前
构建环保之旅:基于 Flutter × OpenHarmony 的垃圾回收个人成就应用
flutter·开源·鸿蒙·openharmony·开源鸿蒙
一起养小猫24 分钟前
Flutter for OpenHarmony 实战 文件存储与数据库操作完全指南
开发语言·jvm·数据库·spring·flutter·harmonyos
游戏开发爱好者81 小时前
抓包工具推荐 2026,网络调试、代理抓包、请求拦截
android·ios·小程序·https·uni-app·iphone·webview
向哆哆1 小时前
Flutter × OpenHarmony 跨端实战:垃圾分类应用页面架构与数据结构设计详解
数据结构·flutter·开源·鸿蒙·openharmony
Mr__proto__1 小时前
Flutter 中使用 Autocomplete 实现智能模糊搜索加历史记录提示
flutter
lbb 小魔仙2 小时前
【Harmonyos】开源鸿蒙跨平台训练营DAY8:Flutter鸿蒙开发指南获取轮播图数据
flutter·华为·harmonyos
2501_944396192 小时前
Flutter for OpenHarmony 视力保护提醒App实战 - 性能优化技巧
android·flutter·性能优化
子春一2 小时前
Flutter for OpenHarmony:构建一个专业级 Flutter 节拍器,深入解析定时器、状态同步与音乐节奏交互设计
javascript·flutter·交互