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
相关推荐
明月看潮生40 分钟前
青少年编程与数学 01-011 系统软件简介 07 iOS操作系统
ios·青少年编程·操作系统·系统软件
90后的晨仔2 小时前
RxSwift 框架解析
前端·ios
qq_279456154 小时前
CADisplayLink、NSTimer、GCD定时器
macos·objective-c·cocoa
可爱小仙子7 小时前
ios苹果系统,js 滑动屏幕、锚定无效
前端·javascript·ios
阅文作家助手开发团队_山神7 小时前
第五章:Flutter Quill渲染原理深度剖析:Delta到RichText的华丽转身
flutter
未来猫咪花7 小时前
# Flutter状态管理对比:view_model vs Riverpod
flutter·ios·android studio
咕噜企业签名分发-淼淼11 小时前
开发源码搭建一码双端应用分发平台教程:逐步分析注意事项
android·ios
键盘敲没电21 小时前
【IOS】GCD学习
学习·ios·objective-c·xcode
SY.ZHOU21 小时前
Significant Location Change
macos·ios·cocoa
阅文作家助手开发团队_山神1 天前
第四章(下) Delta 到 HTML 转换:块级与行内样式渲染深度解析
flutter