Flutter自动打包ios ipa并且上传

该脚本会自动打包ios ipa 并自动上传至苹果后台,中间自动flutter clean ,自动 pod install

里面需要填写自己应用的 apiKey和apiIssuer

如我的例子中apiKey 为 1234 apiIssuer 为5678,

首先flutter 工程目录 新建 shell目录,目录下新建ipa.sh文件,拷贝如下代码

bash 复制代码
#!/bin/bash
###
 # @author: wds
 # @description: 
 # @LastEditTime: 2024-09-04 17:42:02
### 

echo "iOS 打包AppStore渠道包"

# Stop on errors
cd ..
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
echo "Navigating to the iOS directory..."

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 "CocoaPods setup completed successfully."
  
  # Build the iOS app
  echo "Building the iOS app..."
  flutter build ipa --release --target=lib/main.dart
  
  echo "iOS app build completed successfully."

  # 上传
  echo "Upload ipa..."
  xcrun altool --upload-app --type ios -f build/ios/ipa/*.ipa --apiKey 1234 --apiIssuer 5678
  
  echo "Upload ipa successfully."
  
else
  echo "Error: 'ios' directory does not exist."
  exit 1
fi

# Optional: Open the iOS project in Xcode (uncomment if needed)
# echo "Opening iOS project in Xcode..."
# open ios/Runner.xcworkspace

echo "All tasks completed successfully."

运行

bash 复制代码
cd shell
执行 ./ipa.sh
相关推荐
wabil35 分钟前
【LVGL】滑动切换页面的界面优化实践
开发语言·ios·swift
威武的花瓣37 分钟前
调用Page.RegisterAsyncTask()的异步页
ios·iphone
码云数智-园园2 小时前
SwiftUI 6 生产落地踩坑实录
macos·objective-c·cocoa
Digitally18 小时前
5 种简易方法:摩托罗拉手机数据迁移至 iPhone 17
ios·智能手机·iphone
SoaringHeart2 天前
Flutter进阶:基于 EasyRefresh 的下拉刷新封装 n_easy_refresh_mixin.dart
前端·flutter
月光下的丝瓜3 天前
Flutter 国内安装指南
前端·flutter
EricStone3 天前
VibeCoding工程流程学习二:iOS项目架构
ios·vibecoding
天桥吴彦祖5 天前
判断iOS如何监听手机屏幕是否锁屏
ios
恋猫de小郭5 天前
Amper 正式转正 Kotlin Toolchain ,Gradle 未来何去何从
android·前端·flutter
张风捷特烈5 天前
Flutter 类库大揭秘#02 | path_provider 各平台实现
前端·flutter