Flutter ios一键三连脚本

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

## ios 执行命令
- flutter clean
- flutter pub get
- cd ios
- pod install

有,项目根目录创建shell 文件夹,新建setup.sh
在这里插入图片描述
setup.sh里面放如下代码

#!/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

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

cd shell
执行 ./setup.sh

还可以扩展比如总是要生成代码用 flutter pub run build_runner build
可以加到脚本,新建build.sh放如下代码

#!/bin/bash

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

运行

cd shell
执行 ./build.sh

相关推荐

  1. c++国小游戏(喜欢请

    2024-03-12 08:04:05       20 阅读
  2. Nodejs发布脚本

    2024-03-12 08:04:05       59 阅读
  3. 安装docker脚本

    2024-03-12 08:04:05       29 阅读
  4. CentOS安装docker脚本

    2024-03-12 08:04:05       56 阅读
  5. 启动脚本,Karfka,RocketMQ

    2024-03-12 08:04:05       93 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-03-12 08:04:05       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-03-12 08:04:05       100 阅读
  3. 在Django里面运行非项目文件

    2024-03-12 08:04:05       82 阅读
  4. Python语言-面向对象

    2024-03-12 08:04:05       91 阅读

热门阅读

  1. 20240311按键输入实验

    2024-03-12 08:04:05       41 阅读
  2. 使用协程库httpx并发请求

    2024-03-12 08:04:05       44 阅读
  3. 测试推拉视频

    2024-03-12 08:04:05       40 阅读
  4. 前端前置知识pnpm

    2024-03-12 08:04:05       43 阅读
  5. 分布式ID(7):Zookeeper实现分布式ID生成

    2024-03-12 08:04:05       44 阅读
  6. vue的axios是干什么的

    2024-03-12 08:04:05       45 阅读
  7. 迷宫可行路径数

    2024-03-12 08:04:05       49 阅读