Files
customer-im-client-dev/scripts/build_ios.sh

52 lines
1.7 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# iOS Release IPA 打包脚本
#
# Usage:
# bash scripts/build_ios.sh # 使用默认 configdev 配置)
# bash scripts/build_ios.sh prod # 写入 prod 配置后打包CI 使用)
#
# Via melos:
# melos run build:ios
#
# 产物路径:
# IPA → apps/im_app/build/ios/ipa/im_app.ipa
# 符号表 → apps/im_app/build/debug-info/ios/(保留用于线上崩溃还原堆栈)
#
# 前置条件:
# - macOS 环境,已安装 Xcode
# - 已配置签名证书Release scheme 需绑定正式 Provisioning Profile
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ROOT_DIR="$(dirname "$SCRIPT_DIR")"
APP_DIR="$ROOT_DIR/apps/im_app"
CONFIG_FILE="$APP_DIR/config/config.json"
DEBUG_INFO_DIR="$APP_DIR/build/debug-info/ios"
# ── 可选:写入 prod 配置 ────────────────────────────────────────────────────
if [ "${1:-}" = "prod" ]; then
echo "==> Writing prod config..."
cat > "$CONFIG_FILE" <<EOF
{
"IS_DEV": false,
"API_BASE_URL": "${PROD_API_BASE_URL:?PROD_API_BASE_URL is not set}"
}
EOF
fi
# ── 打包 ────────────────────────────────────────────────────────────────────
echo "==> Building iOS release IPA..."
cd "$APP_DIR"
flutter build ipa \
--release \
--no-pub \
--dart-define-from-file=config/config.json \
--split-debug-info="$DEBUG_INFO_DIR" \
--obfuscate
echo ""
echo "✓ IPA: $APP_DIR/build/ios/ipa/im_app.ipa"
echo "✓ 符号表: $DEBUG_INFO_DIR(请妥善保存,用于线上崩溃堆栈还原)"