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
相关推荐
yfmingo2 小时前
flutter项目大量使用.obs会导致项目性能极度下降吗
flutter
山璞2 小时前
Flutter3.32 中使用 webview4.13 与 vue3 项目的 h5 页面通信,以及如何调试
前端·flutter
ezeroyoung3 小时前
环信em_chat_uikit(Flutter)适配鸿蒙
flutter·华为·harmonyos
恋猫de小郭3 小时前
再次紧急修复,Flutter 针对 WebView 无法点击问题增加新的快速修复
android·前端·flutter
denggun123453 小时前
卡顿监测原理
macos·ios·xcode
庄雨山5 小时前
Flutter+Riverpod+开源鸿蒙:新一代跨端状态管理实战
flutter·开源·openharmonyos
遝靑6 小时前
深入 Flutter 底层:自定义 RenderObject 实现高性能异形列表项
flutter
@大迁世界6 小时前
iOS 26.2 引入三种全新 iPhone 自定义方式
ios·iphone
爱吃大芒果6 小时前
Flutter 网络请求完全指南:Dio 封装与拦截器实战
开发语言·javascript·flutter·华为·harmonyos