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
相关推荐
crasowas9 小时前
iOS - 超好用的隐私清单修复脚本(持续更新)
ios·app store
ii_best11 小时前
ios按键精灵脚本开发:ios悬浮窗命令
ios
m0_7482478016 小时前
Flutter Intl包使用指南:实现国际化和本地化
前端·javascript·flutter
Code&Ocean16 小时前
iOS从Matter的设备认证证书中获取VID和PID
ios·matter·chip
/**书香门第*/16 小时前
Laya ios接入goole广告,开始接入 2
ios
迷雾漫步者17 小时前
Flutter组件————PageView
flutter·跨平台·dart
迷雾漫步者1 天前
Flutter组件————FloatingActionButton
前端·flutter·dart
coder_pig1 天前
📝小记:Ubuntu 部署 Jenkins 打包 Flutter APK
flutter·ubuntu·jenkins
捡芝麻丢西瓜1 天前
flutter自学笔记5- dart 编码规范
flutter·dart
恋猫de小郭1 天前
什么?Flutter 可能会被 SwiftUI/ArkUI 化?全新的 Flutter Roadmap
flutter·ios·swiftui