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
相关推荐
LuiChun10 小时前
webview_flutter 4.10.0 技术文档
flutter
ssslar11 小时前
FLUTTER 开发资料集(持续更新)
flutter
taopi202411 小时前
ios打包:uuid与udid
ios·iphone·ipad
LuiChun12 小时前
webview_flutter_wkwebview 3.17.0使用指南
flutter
愿天深海16 小时前
Flutter TextPainter 计算文本高度和行数
flutter
LuiChun17 小时前
webview_flutter_android 4.3.0使用
android·flutter
小鹿撞出了脑震荡1 天前
Effective Objective-C 2.0 读书笔记——关联对象
开发语言·ios·objective-c
小鹿撞出了脑震荡1 天前
Effective Objective-C 2.0 读书笔记—— objc_msgSend
ios·objective-c·xcode
fareast_mzh1 天前
Customize ringtone on your iPhone
ios·iphone
Android西红柿1 天前
flutter-android混合编译,原生接入
android·flutter