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
相关推荐
我想吃辣条30 分钟前
flutter google play 应用不支持 16 KB
android·flutter
LinXunFeng1 小时前
Flutter - Melos Pub workspaces 实践
前端·flutter·架构
Digitally10 小时前
从iPhone转移到itel手机的联系人转移指南
ios·智能手机·iphone
Digitally10 小时前
清除 iPhone 数据以便出售:永久删除您的数据
ios·iphone
勤劳打代码14 小时前
妙笔生花 —— Flutter 实现飞入动画
前端·flutter·设计模式
1024小神17 小时前
关于在ios系统中签名并安装ipa文件的五种方法,PakePlus打包的ipa文件可以看看
macos·ios·cocoa
我想吃辣条17 小时前
flutter mapbox_maps_flutter 应用不支持 16 KB
flutter
QWQ___qwq21 小时前
SwiftUI 的状态管理包装器(Property Wrapper)
ios·swiftui·swift
游戏开发爱好者81 天前
苹果iOS26系统升级:液态玻璃与智能功能全解析
macos·ios·小程序·uni-app·objective-c·cocoa·iphone